namespace SmartSoft.Invoices
{
    using SmartSoft;
    using SmartSoft.Controls;
    using SmartSoft.Controls.ChildGridControls;
    using SmartSoft.ADP;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormCTNXEditor : FormEditor
    {
        private NumericColumn Column1;
        private IContainer components;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
        private GridDetail grdDetail;
        public GridDetail grdSubDetail;
        private LabelControl lblDesc_EN;
        private LabelControl lblDia_Chi;
        private LabelControl lblDien_Giai;
        private LabelControl lblMa_Bp;
        private LabelControl lblMa_Dt;
        private LabelControl lblMa_Hd;
        private LabelControl lblMa_KhoN;
        private LabelControl lblMa_Km;
        private LabelControl lblMa_Nx;
        private LabelControl lblMa_Tte;
        private LabelControl lblOng_Ba;
        private LabelControl lblTTien_Nt0;
        private CTNXDataAccess oMethod;
        private SearchColumn searchColumn1;
        private SearchColumn searchColumn2;
        private DataGridViewTextBoxColumn searchColumn3;
        private NumericColumn searchColumn4;
        private NumericColumn searchColumn5;
        private OptionColumn searchColumn6;
        private TextControl txtDesc_EN;
        private TextControl txtDia_Chi;
        private TextControl txtDien_Giai;
        private TextSearch txtMa_Bp;
        private TextSearch txtMa_Dt;
        private TextSearch txtMa_Hd;
        private TextSearch txtMa_KhoN;
        private TextSearch txtMa_Km;
        private TextSearch txtMa_Nx;
        private TextOption txtMa_Tte;
        private TextControl txtOng_Ba;
        private TextControl txtTen_Bp;
        private TextControl txtTen_Dt;
        private TextControl txtTen_Hd;
        private TextControl txtTen_KhoN;
        private TextControl txtTen_Km;
        private TextControl txtTen_Nx;
        private TextNumeric txtTTien_Nt0;
        private SearchColumn Column9;
        private DataGridViewTextBoxColumn Column10;
        private OptionColumn Column11;
        private SearchColumn Column12;
        private SearchColumn Column13;
        private SearchColumn Column14;
        private SearchColumn Column15;
        private SearchColumn Column16;
        private SearchColumn Column2;
        private SearchLotNumberColumn Column17;
        private DateColumn Column18;
        private NumericColumn Column19;
        private NumericColumn Column20;
        private NumericColumn Column21;
        private NumericColumn Column22;
        private NumericColumn Column23;
        private NumericColumn Column24;
        private TextControl txtTen_DvCs;
        private TextSearch txtMa_DvCsN;
        private LabelControl lblMa_DvCsN;
        private TextNumeric txtTy_Gia;

        public FormCTNXEditor()
        {
            this.oMethod = new CTNXDataAccess();
            this.InitializeComponent();
            this.txtMa_Tte.InputMask = AppInstance.Currencies;
            base.InputTypeTextBox = this.txtMa_Nx;
            base.DetailGridBrowser.CellEnter += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEnter);
            base.DetailGridBrowser.CellEndEdit += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEndEdit);
            base.DetailGridBrowser.CellValidating += new DataGridViewCellValidatingEventHandler(this.DetailGridBrowser_CellValidating);
            base.ResizeForm();
        }

        public FormCTNXEditor(SSInvoiceLib po_SSInvoiceLib) : base(po_SSInvoiceLib)
        {
            this.oMethod = new CTNXDataAccess();
            this.InitializeComponent();
            base.InvoiceCode = po_SSInvoiceLib.InvoiceCode;
            this.txtMa_Tte.InputMask = AppInstance.Currencies;
            base.InputTypeTextBox = this.txtMa_Nx;
            base.DetailGridBrowser.CellEnter += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEnter);
            base.DetailGridBrowser.CellEndEdit += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEndEdit);
            base.DetailGridBrowser.CellValidating += new DataGridViewCellValidatingEventHandler(this.DetailGridBrowser_CellValidating);
            this.SetFunctions();
            base.ResizeForm();
        }

        public FormCTNXEditor(string ps_InvoiceCode, string ps_MasterInvoiceOrder) : base(ps_InvoiceCode, ps_MasterInvoiceOrder)
        {
            this.oMethod = new CTNXDataAccess();
            this.InitializeComponent();
            base.InvoiceCode = ps_InvoiceCode;
            this.txtMa_Tte.InputMask = AppInstance.Currencies;
            base.InputTypeTextBox = this.txtMa_Nx;
            base.DetailGridBrowser.CellEnter += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEnter);
            base.DetailGridBrowser.CellEndEdit += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEndEdit);
            base.DetailGridBrowser.CellValidating += new DataGridViewCellValidatingEventHandler(this.DetailGridBrowser_CellValidating);
            this.SetFunctions();
            base.LocalMasterRow = this.oMethod.GetMasterDataRow(base.SavedMasterOrder);
            base.LocalDetailDataSet = this.oMethod.GetDetailDataSet(base.SavedMasterOrder);
            this.OnShow();
            base.ResizeForm();
        }

        private bool AddNewRow(bool pb_Inserted)
        {
            if ((base.DetailGridBrowser.CurrentRow == null) || (base.DetailGridBrowser.CurrentRow.DataBoundItem == null))
            {
                return false;
            }
            DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
            if (((((decimal) row["So_Luong9"]) == 0M) && (((decimal) row["So_Luong"]) == 0M)) && ((((decimal) row["Tien_Nt"]) == 0M) && (((decimal) row["Tien"]) == 0M)))
            {
                return false;
            }
            int num = 0;
            if (pb_Inserted)
            {
                num = (int) row["Stt_Nv"];
                foreach (DataRow row2 in base.LocalDetailTable.Rows)
                {
                    if ((row2.RowState != DataRowState.Deleted) && (((int) row2["Stt_Nv"]) > num))
                    {
                        row2["Stt_Nv"] = ((int) row2["Stt_Nv"]) + 1;
                    }
                }
            }
            else
            {
                foreach (DataRow row3 in base.LocalDetailTable.Rows)
                {
                    if ((row3.RowState != DataRowState.Deleted) && (((int) row3["Stt_Nv"]) > num))
                    {
                        num = (int) row3["Stt_Nv"];
                    }
                }
                if (((int) row["Stt_Nv"]) < num)
                {
                    return false;
                }
            }
            object obj2 = string.IsNullOrEmpty(this.txtMa_Bp.Text) ? row["Ma_Bp"] : this.txtMa_Bp.Value;
            object obj3 = string.IsNullOrEmpty(this.txtMa_Hd.Text) ? row["Ma_Hd"] : this.txtMa_Hd.Value;
            object obj4 = string.IsNullOrEmpty(this.txtMa_Km.Text) ? row["Ma_Km"] : this.txtMa_Km.Value;
            object obj5 = base.SSInvoiceParameters.AllowProductControl ? (string.IsNullOrEmpty(row["Ma_Sp"].ToString()) ? ((object) base.SSInvoiceParameters.DefaultProcessCode) : row["Ma_Sp"]) : ((object) SDBNull.Value);
            object obj6 = row["Ma_Kho"];
            base.DetailGridBrowser.EndEdit();
            DataRow row4 = base.MakeDetailRow();
            int key = num + 1;
            row4["Stt_Nv"] = key;
            row4["He_So9"] = 1;
            row4["Ma_Bp"] = obj2;
            row4["Ma_Hd"] = obj3;
            row4["Ma_Km"] = obj4;
            row4["Ma_Sp"] = obj5;
            row4["Ma_Kho"] = obj6;
            row4["So_Luong9"] = 0;
            row4["Gia_Nt9"] = 0;
            row4["Gia9"] = 0;
            row4["So_Luong"] = 0;
            row4["Gia_Tb_Tt"] = "C";
            row4["Gia_Nt"] = 0;
            row4["Gia"] = 0;
            row4["Tien_Nt"] = 0;
            row4["Tien"] = 0;
            row4["H_Luong"] = 0;
            row4["Do_Am_PT"] = 0;
            row4["Do_Con_PT"] = 0;
            base.LocalDetailTable.Rows.Add(row4);
            BindingSource dataSource = base.DetailGridBrowser.DataSource as BindingSource;
            dataSource.Position = dataSource.Find(base.DetailOrderString, key);
            return true;
        }

        private void Calculate(int pi_Position)
        {
            DataRow row = ((DataRowView) this.grdDetail.CurrentRow.DataBoundItem).Row;
            this.Calculate(row, pi_Position);
        }

        private void Calculate(DataRow po_Row, int pi_Position)
        {
            if (pi_Position == 1)
            {
                po_Row["So_Luong"] = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["He_So9"]), base.QuantityDecimals);
                if (((decimal) po_Row["So_Luong9"]) != 0M)
                {
                    po_Row["Tien_Nt"] = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["Gia_Nt9"]), base.FCAmountDecimals);
                    po_Row["Tien"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) * base.ExchangeRate, base.LCAmountDecimals);
                    po_Row["Gia_Nt"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) / ((decimal) po_Row["So_Luong"]), base.FCPriceDecimals);
                    po_Row["Gia"] = decimal.Round(((decimal) po_Row["Gia_Nt"]) * base.ExchangeRate, base.LCPriceDecimals);
                }
            }
            else if ((pi_Position == 2) && (((decimal) po_Row["So_Luong9"]) != 0M))
            {
                po_Row["Gia9"] = decimal.Round(((decimal) po_Row["Gia_Nt9"]) * base.ExchangeRate, base.LCPriceDecimals);
                po_Row["Tien_Nt"] = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["Gia_Nt9"]), base.FCAmountDecimals);
                po_Row["Tien"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) * base.ExchangeRate, base.LCAmountDecimals);
                po_Row["Gia_Nt"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) / ((decimal) po_Row["So_Luong"]), base.FCPriceDecimals);
                po_Row["Gia"] = decimal.Round(((decimal) po_Row["Gia_Nt"]) * base.ExchangeRate, base.LCPriceDecimals);
            }
            else if (pi_Position == 3)
            {
                if (((decimal) po_Row["So_Luong9"]) == 0M)
                {
                    po_Row["Tien"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) * base.ExchangeRate, base.LCAmountDecimals);
                }
                else if (((decimal) po_Row["Tien_Nt"]) == 0M)
                {
                    po_Row["Tien_Nt"] = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["Gia_Nt9"]), base.FCAmountDecimals);
                    po_Row["Tien"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) * base.ExchangeRate, base.LCAmountDecimals);
                    po_Row["Gia_Nt"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) / ((decimal) po_Row["So_Luong"]), base.FCPriceDecimals);
                    po_Row["Gia"] = decimal.Round(((decimal) po_Row["Gia_Nt"]) * base.ExchangeRate, base.LCPriceDecimals);
                }
                else if (((decimal) po_Row["Gia_Nt9"]) == 0M)
                {
                    po_Row["Tien"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) * base.ExchangeRate, base.LCAmountDecimals);
                    po_Row["Gia_Nt9"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) / ((decimal) po_Row["So_Luong9"]), base.FCPriceDecimals);
                    po_Row["Gia9"] = decimal.Round(((decimal) po_Row["Gia_Nt9"]) * base.ExchangeRate, base.LCPriceDecimals);
                    po_Row["Gia_Nt"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) / ((decimal) po_Row["So_Luong"]), base.FCPriceDecimals);
                    po_Row["Gia"] = decimal.Round(((decimal) po_Row["Gia_Nt"]) * base.ExchangeRate, base.LCPriceDecimals);
                }
                else
                {
                    decimal num = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["Gia_Nt9"]), base.FCAmountDecimals);
                    if ((((decimal) po_Row["Tien_Nt"]) < (num - base.DiffAmountRange)) || (((decimal) po_Row["Tien_Nt"]) > (num + base.DiffAmountRange)))
                    {
                        po_Row["Tien_Nt"] = num;
                        po_Row["Tien"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) * base.ExchangeRate, base.LCAmountDecimals);
                        po_Row["Gia_Nt9"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) / ((decimal) po_Row["So_Luong9"]), base.FCPriceDecimals);
                        po_Row["Gia9"] = decimal.Round(((decimal) po_Row["Gia_Nt9"]) * base.ExchangeRate, base.LCPriceDecimals);
                        po_Row["Gia_Nt"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) / ((decimal) po_Row["So_Luong"]), base.FCPriceDecimals);
                        po_Row["Gia"] = decimal.Round(((decimal) po_Row["Gia_Nt"]) * base.ExchangeRate, base.LCPriceDecimals);
                    }
                    else
                    {
                        po_Row["Tien"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) * base.ExchangeRate, base.LCAmountDecimals);
                        po_Row["Gia_Nt"] = decimal.Round(((decimal) po_Row["Tien_Nt"]) / ((decimal) po_Row["So_Luong"]), base.FCPriceDecimals);
                        po_Row["Gia"] = decimal.Round(((decimal) po_Row["Gia_Nt"]) * base.ExchangeRate, base.LCPriceDecimals);
                    }
                }
            }
            po_Row.EndEdit();
        }

        private void ChooseCommand(object sender, EventArgs e)
        {
            if (base.txtNgay_Ct.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập ngày chứng từ!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else if (this.txtMa_Dt.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập mã đối tượng!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else if (this.txtMa_Nx.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập mã nhập xuất!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                DataRow row;
                DataTable table = new DataTable();
                DataColumn column = new DataColumn("Stt0_D", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Bp", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Hd", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Vt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ten_Vt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Dvt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("He_So9", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("So_Luong", typeof(decimal));
                table.Columns.Add(column);
                table.PrimaryKey = new DataColumn[] { table.Columns["Stt0_D"] };
                foreach (DataRow row2 in base.LocalDetailTable.Rows)
                {
                    if (((row2.RowState != DataRowState.Deleted) && !string.IsNullOrEmpty(row2["Ma_Vt"].ToString())) && (!string.IsNullOrEmpty(row2["Stt0_D"].ToString()) && (table.Rows.Find(row2["Stt0_D"]) == null)))
                    {
                        row = table.NewRow();
                        row["Stt0_D"] = row2["Stt0_D"];
                        row["Ma_Bp"] = row2["Ma_Bp"];
                        row["Ma_Hd"] = row2["Ma_Hd"];
                        row["Ma_Vt"] = row2["Ma_Vt"];
                        row["Ten_Vt"] = row2["Ten_Vt"];
                        row["Dvt"] = row2["Dvt"];
                        row["He_So9"] = row2["He_So9"];
                        row["So_Luong"] = row2["So_Luong"];
                        table.Rows.Add(row);
                    }
                }
                //FormCTSX0F4Editor editor = new FormCTSX0F4Editor(base.SavedMasterOrder, base.txtNgay_Ct.Value, table);
                //editor.ShowDialog();
            //    if (editor.CheckAccepted)
            //    {
            //        int num = 0;
            //        object obj2 = "";
            //        object obj3 = "";
            //        object obj4 = 0;
            //        object obj5 = 0;
            //        base.LocalDetailTable.AcceptChanges();
            //        foreach (DataRow row3 in base.LocalDetailTable.Rows)
            //        {
            //            if (row3.RowState != DataRowState.Deleted)
            //            {
            //                row3.Delete();
            //            }
            //        }
            //        foreach (DataRow row4 in table.Rows)
            //        {
            //            if (((row4.RowState != DataRowState.Deleted) && !row4["So_Luong"].Equals(DBNull.Value)) && !(((decimal) row4["So_Luong"]) == 0M))
            //            {
            //                num++;
            //                row = base.MakeDetailRow();
            //                obj2 = string.IsNullOrEmpty(row4["Ma_Bp"].ToString()) ? this.txtMa_Bp.Value : row4["Ma_Bp"];
            //                obj3 = string.IsNullOrEmpty(row4["Ma_Hd"].ToString()) ? this.txtMa_Hd.Value : row4["Ma_Hd"];
            //                obj5 = row4["So_Luong"];
            //                obj4 = decimal.Round(((decimal) obj5) / ((decimal) row4["He_So9"]), base.QuantityDecimals);
            //                row["Stt0_D"] = row4["Stt0_D"];
            //                row["Stt_Nv"] = num;
            //                row["Ma_Vt"] = row4["Ma_Vt"];
            //                row["Ten_Vt"] = row4["Ten_Vt"];
            //                row["Dvt"] = row4["Dvt"];
            //                row["He_So9"] = row4["He_So9"];
            //                row["Ma_Bp"] = obj2;
            //                row["Ma_Hd"] = obj3;
            //                row["So_Luong9"] = obj4;
            //                row["So_Luong"] = obj5;
            //                row["Gia_Tb_Tt"] = "K";
            //                row["Gia_Nt9"] = 0;
            //                row["Gia9"] = 0;
            //                row["Gia_Nt"] = 0;
            //                row["Gia"] = 0;
            //                row["Tien_Nt"] = 0;
            //                row["Tien"] = 0;
            //                row["H_Luong"] = 0;
            //                row["Do_Am_PT"] = 0;
            //                row["Do_Con_PT"] = 0;
            //                this.UpdateVtParameters(row);
            //                base.LocalDetailTable.Rows.Add(row);
            //            }
            //        }
            //        base.DetailGridBrowser.CurrentCell = base.DetailGridBrowser.FirstDisplayedCell;
            //        base.DetailGridBrowser.Focus();
            //    }
            }
        }

        private void ChooseCommandItem(object sender, EventArgs e)
        {
            if (base.txtNgay_Ct.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập ngày chứng từ!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else if (this.txtMa_Dt.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập mã đối tượng!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else if (this.txtMa_Nx.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập mã nhập xuất!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                DataRow row;
                DataTable table = new DataTable();
                DataColumn column = new DataColumn("Stt0_D", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Bp", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Hd", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Kho", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Vt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ten_Vt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Dvt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Lo_Hang", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Han_Dung", typeof(DateTime));
                table.Columns.Add(column);
                column = new DataColumn("H_Luong", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("Do_Am_PT", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("Do_Con_PT", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("So_Luong", typeof(decimal));
                table.Columns.Add(column);
                table.PrimaryKey = new DataColumn[] { table.Columns["Stt0_D"], table.Columns["Ma_Kho"], table.Columns["Ma_Vt"], table.Columns["Lo_Hang"] };
                foreach (DataRow row2 in base.LocalDetailTable.Rows)
                {
                    if (((row2.RowState != DataRowState.Deleted) && !string.IsNullOrEmpty(row2["Ma_Vt"].ToString())) && !string.IsNullOrEmpty(row2["Stt0_D"].ToString()))
                    {
                        object[] keys = new object[] { row2["Stt0_D"], row2["Ma_Kho"], row2["Ma_Vt"], row2["Lo_Hang"] };
                        if (table.Rows.Find(keys) == null)
                        {
                            row = table.NewRow();
                            row["Stt0_D"] = row2["Stt0_D"];
                            row["Ma_Bp"] = row2["Ma_Bp"];
                            row["Ma_Hd"] = row2["Ma_Hd"];
                            row["Ma_Kho"] = row2["Ma_Kho"];
                            row["Ma_Vt"] = row2["Ma_Vt"];
                            row["Ten_Vt"] = row2["Ten_Vt"];
                            row["Dvt"] = row2["Dvt"];
                            row["Lo_Hang"] = row2["Lo_Hang"];
                            row["Han_Dung"] = row2["Han_Dung"];
                            row["H_Luong"] = row2["H_Luong"];
                            row["Do_Am_PT"] = row2["Do_Am_PT"];
                            row["Do_Con_PT"] = row2["Do_Con_PT"];
                            row["So_Luong"] = row2["So_Luong"];
                            table.Rows.Add(row);
                        }
                    }
                }
                //FormCTSX1F4Editor editor = new FormCTSX1F4Editor(base.SavedMasterOrder, base.txtNgay_Ct.Value, table);
                //editor.ShowDialog();
                //if (editor.CheckAccepted)
                //{
                //    int num = 0;
                //    object obj2 = "";
                //    object obj3 = "";
                //    base.LocalDetailTable.AcceptChanges();
                //    foreach (DataRow row3 in base.LocalDetailTable.Rows)
                //    {
                //        if (row3.RowState != DataRowState.Deleted)
                //        {
                //            row3.Delete();
                //        }
                //    }
                //    foreach (DataRow row4 in table.Rows)
                //    {
                //        if (((row4.RowState != DataRowState.Deleted) && !row4["So_Luong"].Equals(DBNull.Value)) && !(((decimal) row4["So_Luong"]) == 0M))
                //        {
                //            num++;
                //            row = base.MakeDetailRow();
                //            obj2 = string.IsNullOrEmpty(row4["Ma_Bp"].ToString()) ? this.txtMa_Bp.Value : row4["Ma_Bp"];
                //            obj3 = string.IsNullOrEmpty(row4["Ma_Hd"].ToString()) ? this.txtMa_Hd.Value : row4["Ma_Hd"];
                //            row["Stt0_D"] = row4["Stt0_D"];
                //            row["Stt_Nv"] = num;
                //            row["Ma_Kho"] = row4["Ma_Kho"];
                //            row["Ma_Vt"] = row4["Ma_Vt"];
                //            row["Ten_Vt"] = row4["Ten_Vt"];
                //            row["Dvt"] = row4["Dvt"];
                //            row["He_So9"] = 1;
                //            row["Ma_Bp"] = obj2;
                //            row["Ma_Hd"] = obj3;
                //            row["So_Luong9"] = row4["So_Luong"];
                //            row["So_Luong"] = row4["So_Luong"];
                //            row["Gia_Tb_Tt"] = "C";
                //            row["Gia_Nt9"] = 0;
                //            row["Gia9"] = 0;
                //            row["Gia_Nt"] = 0;
                //            row["Gia"] = 0;
                //            row["Tien_Nt"] = 0;
                //            row["Tien"] = 0;
                //            row["Lo_Hang"] = row4["Lo_Hang"];
                //            row["Han_Dung"] = row4["Han_Dung"];
                //            row["H_Luong"] = row4["H_Luong"];
                //            row["Do_Am_PT"] = row4["Do_Am_PT"];
                //            row["Do_Con_PT"] = row4["Do_Con_PT"];
                //            this.UpdateVtParameters(row);
                //            base.LocalDetailTable.Rows.Add(row);
                //        }
                //    }
                //    base.DetailGridBrowser.CurrentCell = base.DetailGridBrowser.FirstDisplayedCell;
                //    base.DetailGridBrowser.Focus();
                //}
            }
        }

        private void DetailGridBrowser_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                this.UpdateVtParameters();
            }
            else if (e.ColumnIndex == 2)
            {
                this.SetItemRatio();
            }
            else if (e.ColumnIndex == 14)
            {
                this.Calculate(1);
                this.Sum();
            }
            else if (e.ColumnIndex == 15)
            {
                this.Calculate(2);
                this.Sum();
            }
            else if (e.ColumnIndex == 0x10)
            {
                this.Calculate(3);
                this.Sum();
            }
        }

        private void DetailGridBrowser_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 2)
            {
                this.SetItemUnits();
            }
            else if (e.ColumnIndex == 9)
            {
                object obj2 = ((base.SSInvoiceParameters.InvoiceCode == "PNDC") && !string.IsNullOrEmpty(this.txtMa_KhoN.Text)) ? this.txtMa_KhoN.Value : SDBNull.Value;
                DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
                (base.DetailGridBrowser.CurrentCell as SearchLotNumberCell).InvoicePosted = base.LocalMasterRow["Posted"];
                (base.DetailGridBrowser.CurrentCell as SearchLotNumberCell).InvoiceDate = (DateTime) base.txtNgay_Ct.Value;
                (base.DetailGridBrowser.CurrentCell as SearchLotNumberCell).MasterKey = base.SavedMasterOrder;
                (base.DetailGridBrowser.CurrentCell as SearchLotNumberCell).DetailKey = base.SavedDetailOrder;
                (base.DetailGridBrowser.CurrentCell as SearchLotNumberCell).InventoryCode = row["Ma_Kho"];
                (base.DetailGridBrowser.CurrentCell as SearchLotNumberCell).InventoryInputCode = obj2;
                (base.DetailGridBrowser.CurrentCell as SearchLotNumberCell).LocalItemCode = row["Ma_Vt"];
                (base.DetailGridBrowser.CurrentCell as SearchLotNumberCell).LocalDetailTable = base.LocalDetailTable;
            }
        }

        private void DetailGridBrowser_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (((AppInstance.StockWarning != 0) && ((base.DetailGridBrowser.CurrentRow != null) && (base.DetailGridBrowser.CurrentRow.DataBoundItem != null))) && (e.ColumnIndex == 14))
            {
                string str = "";
                object obj2 = ((base.SSInvoiceParameters.InvoiceCode == "PNDC") && !string.IsNullOrEmpty(this.txtMa_KhoN.Text)) ? this.txtMa_KhoN.Value : SDBNull.Value;
                DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
                if (base.DetailGridBrowser.CurrentCell.IsInEditMode)
                {
                    row["So_Luong9"] = Convert.ToDecimal(string.IsNullOrEmpty(e.FormattedValue.ToString()) ? "0" : e.FormattedValue);
                    this.Calculate(row, 1);
                    this.Sum();
                }
                if ((base.SSInvoiceParameters.InvoiceType == "2") && !base.SSInvoiceParameters.MakeLotQtyWarningMessage(base.LocalMasterRow["Posted"], base.SavedMasterOrder, row["Stt0"], base.txtNgay_Ct.Value, base.SSInvoiceParameters.InvoiceType, row["Ma_Kho"], row["Ma_Vt"], obj2, row["Lo_Hang"], base.LocalDetailTable, ref str))
                {
                    e.Cancel = true;
                    (base.DetailGridBrowser.CurrentCell as NumericCell).CheckMovable = false;
                    MessageBox.Show(str, AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    e.Cancel = false;
                    (base.DetailGridBrowser.CurrentCell as NumericCell).CheckMovable = true;
                    if (!base.SSInvoiceParameters.MakeQtyWarningMessage(false, base.LocalMasterRow["Posted"], base.SavedMasterOrder, row["Stt0"], base.txtNgay_Ct.Value, base.SSInvoiceParameters.InvoiceType, row["Ma_Kho"], row["Ma_Vt"], obj2, base.LocalDetailTable, ref str))
                    {
                        if (AppInstance.StockWarning == 2)
                        {
                            e.Cancel = true;
                            (base.DetailGridBrowser.CurrentCell as NumericCell).CheckMovable = false;
                        }
                        else
                        {
                            e.Cancel = false;
                            (base.DetailGridBrowser.CurrentCell as NumericCell).CheckMovable = true;
                        }
                        MessageBox.Show(str, AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                }
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void grdDetail_CellBottomLeftLeaved(object sender, EventArgs e)
        {
            if (((base.DetailGridBrowser.Rows.Count == 1) || !string.IsNullOrEmpty(((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row["Ma_Vt"].ToString())) || !string.IsNullOrEmpty(base.ActiveControl.Text))
            {
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.NextCell;
            }
            else
            {
                this.txtMa_KhoN.Focus();
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.DeleteCurrentRow;
            }
        }

        private void grdDetail_CellRightLeaved(object sender, EventArgs e)
        {
            if (this.AddNewRow(false))
            {
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.FirstCell;
            }
            else
            {
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.FirstCellNextRow;
            }
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormCTNXEditor));
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle();
            this.txtDesc_EN = new SmartSoft.Controls.TextControl();
            this.txtDien_Giai = new SmartSoft.Controls.TextControl();
            this.txtTen_Hd = new SmartSoft.Controls.TextControl();
            this.txtTen_Bp = new SmartSoft.Controls.TextControl();
            this.lblDesc_EN = new SmartSoft.Controls.LabelControl();
            this.lblDien_Giai = new SmartSoft.Controls.LabelControl();
            this.txtMa_Hd = new SmartSoft.Controls.TextSearch();
            this.lblMa_Hd = new SmartSoft.Controls.LabelControl();
            this.txtMa_Bp = new SmartSoft.Controls.TextSearch();
            this.lblMa_Bp = new SmartSoft.Controls.LabelControl();
            this.txtMa_Tte = new SmartSoft.Controls.TextOption();
            this.txtTy_Gia = new SmartSoft.Controls.TextNumeric();
            this.txtDia_Chi = new SmartSoft.Controls.TextControl();
            this.txtOng_Ba = new SmartSoft.Controls.TextControl();
            this.txtTen_Dt = new SmartSoft.Controls.TextControl();
            this.lblMa_Tte = new SmartSoft.Controls.LabelControl();
            this.txtMa_Dt = new SmartSoft.Controls.TextSearch();
            this.lblDia_Chi = new SmartSoft.Controls.LabelControl();
            this.lblOng_Ba = new SmartSoft.Controls.LabelControl();
            this.lblMa_Dt = new SmartSoft.Controls.LabelControl();
            this.txtTTien_Nt0 = new SmartSoft.Controls.TextNumeric();
            this.lblTTien_Nt0 = new SmartSoft.Controls.LabelControl();
            this.lblMa_Km = new SmartSoft.Controls.LabelControl();
            this.txtMa_Km = new SmartSoft.Controls.TextSearch();
            this.txtTen_Km = new SmartSoft.Controls.TextControl();
            this.lblMa_Nx = new SmartSoft.Controls.LabelControl();
            this.txtMa_Nx = new SmartSoft.Controls.TextSearch();
            this.txtTen_Nx = new SmartSoft.Controls.TextControl();
            this.lblMa_KhoN = new SmartSoft.Controls.LabelControl();
            this.grdDetail = new SmartSoft.Controls.GridDetail();
            this.Column9 = new SmartSoft.Controls.ChildGridControls.SearchColumn();
            this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column11 = new SmartSoft.Controls.ChildGridControls.OptionColumn();
            this.Column12 = new SmartSoft.Controls.ChildGridControls.SearchColumn();
            this.Column13 = new SmartSoft.Controls.ChildGridControls.SearchColumn();
            this.Column14 = new SmartSoft.Controls.ChildGridControls.SearchColumn();
            this.Column15 = new SmartSoft.Controls.ChildGridControls.SearchColumn();
            this.Column16 = new SmartSoft.Controls.ChildGridControls.SearchColumn();
            this.Column2 = new SmartSoft.Controls.ChildGridControls.SearchColumn();
            this.Column17 = new SmartSoft.Controls.ChildGridControls.SearchLotNumberColumn();
            this.Column18 = new SmartSoft.Controls.ChildGridControls.DateColumn();
            this.Column19 = new SmartSoft.Controls.ChildGridControls.NumericColumn();
            this.Column20 = new SmartSoft.Controls.ChildGridControls.NumericColumn();
            this.Column21 = new SmartSoft.Controls.ChildGridControls.NumericColumn();
            this.Column22 = new SmartSoft.Controls.ChildGridControls.NumericColumn();
            this.Column23 = new SmartSoft.Controls.ChildGridControls.NumericColumn();
            this.Column24 = new SmartSoft.Controls.ChildGridControls.NumericColumn();
            this.grdSubDetail = new SmartSoft.Controls.GridDetail();
            this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.searchColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column1 = new SmartSoft.Controls.ChildGridControls.NumericColumn();
            this.searchColumn4 = new SmartSoft.Controls.ChildGridControls.NumericColumn();
            this.searchColumn5 = new SmartSoft.Controls.ChildGridControls.NumericColumn();
            this.searchColumn6 = new SmartSoft.Controls.ChildGridControls.OptionColumn();
            this.searchColumn1 = new SmartSoft.Controls.ChildGridControls.SearchColumn();
            this.searchColumn2 = new SmartSoft.Controls.ChildGridControls.SearchColumn();
            this.txtMa_KhoN = new SmartSoft.Controls.TextSearch();
            this.txtTen_KhoN = new SmartSoft.Controls.TextControl();
            this.txtTen_DvCs = new SmartSoft.Controls.TextControl();
            this.txtMa_DvCsN = new SmartSoft.Controls.TextSearch();
            this.lblMa_DvCsN = new SmartSoft.Controls.LabelControl();
            ((System.ComponentModel.ISupportInitialize)(this.grdDetail)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.grdSubDetail)).BeginInit();
            this.SuspendLayout();
            // 
            // txtMa_Loai1
            // 
            this.txtMa_Loai1.TabIndex = 27;
            // 
            // txtMa_Loai2
            // 
            this.txtMa_Loai2.TabIndex = 28;
            // 
            // txtMa_Loai3
            // 
            this.txtMa_Loai3.TabIndex = 29;
            // 
            // txtNgay_Ps
            // 
            this.txtNgay_Ps.TabIndex = 0;
            // 
            // txtSo_Ct
            // 
            this.txtSo_Ct.TabIndex = 2;
            // 
            // txtDesc_EN
            // 
            this.txtDesc_EN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.txtDesc_EN.CheckTextSearched = false;
            this.txtDesc_EN.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtDesc_EN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDesc_EN.Location = new System.Drawing.Point(487, 158);
            this.txtDesc_EN.MaxLength = 254;
            this.txtDesc_EN.Name = "txtDesc_EN";
            this.txtDesc_EN.OldValue = null;
            this.txtDesc_EN.Size = new System.Drawing.Size(295, 20);
            this.txtDesc_EN.TabIndex = 17;
            this.txtDesc_EN.UserTextLength = SmartSoft.AppInstance.TextControlLength.InvoiceDescription;
            this.txtDesc_EN.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtDesc_EN.Value = ((object)(resources.GetObject("txtDesc_EN.Value")));
            // 
            // txtDien_Giai
            // 
            this.txtDien_Giai.CheckTextSearched = false;
            this.txtDien_Giai.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtDien_Giai.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDien_Giai.Location = new System.Drawing.Point(99, 158);
            this.txtDien_Giai.MaxLength = 254;
            this.txtDien_Giai.Name = "txtDien_Giai";
            this.txtDien_Giai.OldValue = null;
            this.txtDien_Giai.Size = new System.Drawing.Size(296, 20);
            this.txtDien_Giai.TabIndex = 16;
            this.txtDien_Giai.UserTextLength = SmartSoft.AppInstance.TextControlLength.InvoiceDescription;
            this.txtDien_Giai.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtDien_Giai.Value = ((object)(resources.GetObject("txtDien_Giai.Value")));
            // 
            // txtTen_Hd
            // 
            this.txtTen_Hd.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Hd.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Hd.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Hd.CheckTextSearched = false;
            this.txtTen_Hd.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Hd.Enabled = false;
            this.txtTen_Hd.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Hd.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Hd.Location = new System.Drawing.Point(223, 98);
            this.txtTen_Hd.Name = "txtTen_Hd";
            this.txtTen_Hd.OldValue = null;
            this.txtTen_Hd.Size = new System.Drawing.Size(559, 13);
            this.txtTen_Hd.TabIndex = 11;
            this.txtTen_Hd.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_Hd.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Hd.Value = ((object)(resources.GetObject("txtTen_Hd.Value")));
            // 
            // txtTen_Bp
            // 
            this.txtTen_Bp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Bp.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Bp.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Bp.CheckTextSearched = false;
            this.txtTen_Bp.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Bp.Enabled = false;
            this.txtTen_Bp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Bp.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Bp.Location = new System.Drawing.Point(223, 77);
            this.txtTen_Bp.Name = "txtTen_Bp";
            this.txtTen_Bp.OldValue = null;
            this.txtTen_Bp.Size = new System.Drawing.Size(559, 13);
            this.txtTen_Bp.TabIndex = 9;
            this.txtTen_Bp.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_Bp.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Bp.Value = ((object)(resources.GetObject("txtTen_Bp.Value")));
            // 
            // lblDesc_EN
            // 
            this.lblDesc_EN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblDesc_EN.AutoSize = true;
            this.lblDesc_EN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDesc_EN.Location = new System.Drawing.Point(410, 161);
            this.lblDesc_EN.Name = "lblDesc_EN";
            this.lblDesc_EN.Size = new System.Drawing.Size(71, 14);
            this.lblDesc_EN.TabIndex = 80;
            this.lblDesc_EN.Text = "Diễn giải (EN)";
            // 
            // lblDien_Giai
            // 
            this.lblDien_Giai.AutoSize = true;
            this.lblDien_Giai.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDien_Giai.Location = new System.Drawing.Point(12, 160);
            this.lblDien_Giai.Name = "lblDien_Giai";
            this.lblDien_Giai.Size = new System.Drawing.Size(73, 14);
            this.lblDien_Giai.TabIndex = 81;
            this.lblDien_Giai.Text = "Diễn giải (VN)";
            // 
            // txtMa_Hd
            // 
            this.txtMa_Hd.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Hd.CheckTextSearched = false;
            this.txtMa_Hd.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Hd.EmptyIsValid = true;
            this.txtMa_Hd.FieldDisplay = "Ten_Hd";
            this.txtMa_Hd.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Hd.FoundIsValid = true;
            this.txtMa_Hd.Location = new System.Drawing.Point(99, 95);
            this.txtMa_Hd.MaxLength = 32;
            this.txtMa_Hd.Name = "txtMa_Hd";
            this.txtMa_Hd.OldValue = null;
            this.txtMa_Hd.Size = new System.Drawing.Size(118, 20);
            this.txtMa_Hd.TabIndex = 10;
            this.txtMa_Hd.TableName = "DMHD";
            this.txtMa_Hd.TextDisplay = this.txtTen_Hd;
            this.txtMa_Hd.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Hd.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Hd.Value = ((object)(resources.GetObject("txtMa_Hd.Value")));
            this.txtMa_Hd.Validated += new System.EventHandler(this.txtMa_Hd_Validated);
            // 
            // lblMa_Hd
            // 
            this.lblMa_Hd.AutoSize = true;
            this.lblMa_Hd.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Hd.Location = new System.Drawing.Point(12, 98);
            this.lblMa_Hd.Name = "lblMa_Hd";
            this.lblMa_Hd.Size = new System.Drawing.Size(54, 14);
            this.lblMa_Hd.TabIndex = 82;
            this.lblMa_Hd.Text = "Hợp đồng";
            // 
            // txtMa_Bp
            // 
            this.txtMa_Bp.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Bp.CheckTextSearched = false;
            this.txtMa_Bp.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Bp.EmptyIsValid = true;
            this.txtMa_Bp.FieldDisplay = "Ten_Bp";
            this.txtMa_Bp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Bp.FoundIsValid = true;
            this.txtMa_Bp.Location = new System.Drawing.Point(99, 74);
            this.txtMa_Bp.MaxLength = 32;
            this.txtMa_Bp.Name = "txtMa_Bp";
            this.txtMa_Bp.OldValue = null;
            this.txtMa_Bp.Size = new System.Drawing.Size(118, 20);
            this.txtMa_Bp.TabIndex = 8;
            this.txtMa_Bp.TableName = "DMBP";
            this.txtMa_Bp.TextDisplay = this.txtTen_Bp;
            this.txtMa_Bp.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Bp.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Bp.Value = ((object)(resources.GetObject("txtMa_Bp.Value")));
            this.txtMa_Bp.Validated += new System.EventHandler(this.txtMa_Bp_Validated);
            // 
            // lblMa_Bp
            // 
            this.lblMa_Bp.AutoSize = true;
            this.lblMa_Bp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Bp.Location = new System.Drawing.Point(12, 77);
            this.lblMa_Bp.Name = "lblMa_Bp";
            this.lblMa_Bp.Size = new System.Drawing.Size(47, 14);
            this.lblMa_Bp.TabIndex = 83;
            this.lblMa_Bp.Text = "Bộ phận";
            // 
            // txtMa_Tte
            // 
            this.txtMa_Tte.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.txtMa_Tte.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Tte.CheckTextSearched = false;
            this.txtMa_Tte.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtMa_Tte.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Tte.InputMask = "USD,VND";
            this.txtMa_Tte.Location = new System.Drawing.Point(697, 53);
            this.txtMa_Tte.Name = "txtMa_Tte";
            this.txtMa_Tte.OldValue = null;
            this.txtMa_Tte.Size = new System.Drawing.Size(28, 20);
            this.txtMa_Tte.TabIndex = 6;
            this.txtMa_Tte.Text = "USD";
            this.txtMa_Tte.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtMa_Tte.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtMa_Tte.Value = "USD";
            this.txtMa_Tte.Validated += new System.EventHandler(this.txtMa_Tte_Validated);
            // 
            // txtTy_Gia
            // 
            this.txtTy_Gia.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTy_Gia.BackColor = System.Drawing.Color.White;
            this.txtTy_Gia.DisabledBackColor = System.Drawing.Color.Empty;
            this.txtTy_Gia.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTy_Gia.ForeColor = System.Drawing.Color.Black;
            this.txtTy_Gia.Location = new System.Drawing.Point(724, 53);
            this.txtTy_Gia.Name = "txtTy_Gia";
            this.txtTy_Gia.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtTy_Gia.OldValue = null;
            this.txtTy_Gia.Size = new System.Drawing.Size(58, 20);
            this.txtTy_Gia.TabIndex = 7;
            this.txtTy_Gia.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtTy_Gia.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.ExchangeRate;
            this.txtTy_Gia.Value = ((object)(resources.GetObject("txtTy_Gia.Value")));
            this.txtTy_Gia.Validated += new System.EventHandler(this.txtTy_Gia_Validated);
            // 
            // txtDia_Chi
            // 
            this.txtDia_Chi.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.txtDia_Chi.CheckTextSearched = false;
            this.txtDia_Chi.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtDia_Chi.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDia_Chi.Location = new System.Drawing.Point(487, 137);
            this.txtDia_Chi.MaxLength = 128;
            this.txtDia_Chi.Name = "txtDia_Chi";
            this.txtDia_Chi.OldValue = null;
            this.txtDia_Chi.Size = new System.Drawing.Size(295, 20);
            this.txtDia_Chi.TabIndex = 15;
            this.txtDia_Chi.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtDia_Chi.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtDia_Chi.Value = ((object)(resources.GetObject("txtDia_Chi.Value")));
            // 
            // txtOng_Ba
            // 
            this.txtOng_Ba.CheckTextSearched = false;
            this.txtOng_Ba.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtOng_Ba.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtOng_Ba.Location = new System.Drawing.Point(99, 137);
            this.txtOng_Ba.MaxLength = 128;
            this.txtOng_Ba.Name = "txtOng_Ba";
            this.txtOng_Ba.OldValue = null;
            this.txtOng_Ba.Size = new System.Drawing.Size(296, 20);
            this.txtOng_Ba.TabIndex = 14;
            this.txtOng_Ba.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtOng_Ba.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtOng_Ba.Value = ((object)(resources.GetObject("txtOng_Ba.Value")));
            // 
            // txtTen_Dt
            // 
            this.txtTen_Dt.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Dt.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Dt.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Dt.CheckTextSearched = false;
            this.txtTen_Dt.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Dt.Enabled = false;
            this.txtTen_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Dt.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Dt.Location = new System.Drawing.Point(223, 119);
            this.txtTen_Dt.Name = "txtTen_Dt";
            this.txtTen_Dt.OldValue = null;
            this.txtTen_Dt.Size = new System.Drawing.Size(559, 13);
            this.txtTen_Dt.TabIndex = 13;
            this.txtTen_Dt.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_Dt.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Dt.Value = ((object)(resources.GetObject("txtTen_Dt.Value")));
            // 
            // lblMa_Tte
            // 
            this.lblMa_Tte.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblMa_Tte.AutoSize = true;
            this.lblMa_Tte.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Tte.Location = new System.Drawing.Point(652, 56);
            this.lblMa_Tte.Name = "lblMa_Tte";
            this.lblMa_Tte.Size = new System.Drawing.Size(39, 14);
            this.lblMa_Tte.TabIndex = 93;
            this.lblMa_Tte.Text = "Tiền tệ";
            // 
            // txtMa_Dt
            // 
            this.txtMa_Dt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Dt.CheckTextSearched = false;
            this.txtMa_Dt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Dt.FieldDisplay = "Ten_Dt";
            this.txtMa_Dt.FirstFilter = "Is_Stop = \'1\'";
            this.txtMa_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Dt.Location = new System.Drawing.Point(99, 116);
            this.txtMa_Dt.MaxLength = 32;
            this.txtMa_Dt.Name = "txtMa_Dt";
            this.txtMa_Dt.OldValue = null;
            this.txtMa_Dt.Size = new System.Drawing.Size(118, 20);
            this.txtMa_Dt.TabIndex = 12;
            this.txtMa_Dt.TableName = "DMDT";
            this.txtMa_Dt.TextDisplay = this.txtTen_Dt;
            this.txtMa_Dt.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Dt.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Dt.Value = ((object)(resources.GetObject("txtMa_Dt.Value")));
            this.txtMa_Dt.Validated += new System.EventHandler(this.txtMa_Dt_Validated);
            // 
            // lblDia_Chi
            // 
            this.lblDia_Chi.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblDia_Chi.AutoSize = true;
            this.lblDia_Chi.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDia_Chi.Location = new System.Drawing.Point(441, 140);
            this.lblDia_Chi.Name = "lblDia_Chi";
            this.lblDia_Chi.Size = new System.Drawing.Size(40, 14);
            this.lblDia_Chi.TabIndex = 95;
            this.lblDia_Chi.Text = "Địa chỉ";
            // 
            // lblOng_Ba
            // 
            this.lblOng_Ba.AutoSize = true;
            this.lblOng_Ba.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblOng_Ba.Location = new System.Drawing.Point(12, 140);
            this.lblOng_Ba.Name = "lblOng_Ba";
            this.lblOng_Ba.Size = new System.Drawing.Size(42, 14);
            this.lblOng_Ba.TabIndex = 96;
            this.lblOng_Ba.Text = "Ông bà";
            // 
            // lblMa_Dt
            // 
            this.lblMa_Dt.AutoSize = true;
            this.lblMa_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Dt.Location = new System.Drawing.Point(12, 119);
            this.lblMa_Dt.Name = "lblMa_Dt";
            this.lblMa_Dt.Size = new System.Drawing.Size(55, 14);
            this.lblMa_Dt.TabIndex = 94;
            this.lblMa_Dt.Text = "Đối tượng";
            // 
            // txtTTien_Nt0
            // 
            this.txtTTien_Nt0.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTTien_Nt0.BackColor = System.Drawing.Color.White;
            this.txtTTien_Nt0.Enabled = false;
            this.txtTTien_Nt0.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTTien_Nt0.ForeColor = System.Drawing.Color.Black;
            this.txtTTien_Nt0.Location = new System.Drawing.Point(674, 466);
            this.txtTTien_Nt0.Name = "txtTTien_Nt0";
            this.txtTTien_Nt0.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtTTien_Nt0.OldValue = null;
            this.txtTTien_Nt0.Size = new System.Drawing.Size(108, 20);
            this.txtTTien_Nt0.TabIndex = 26;
            this.txtTTien_Nt0.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtTTien_Nt0.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.ForeignAmount;
            this.txtTTien_Nt0.Value = ((object)(resources.GetObject("txtTTien_Nt0.Value")));
            // 
            // lblTTien_Nt0
            // 
            this.lblTTien_Nt0.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.lblTTien_Nt0.AutoSize = true;
            this.lblTTien_Nt0.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTTien_Nt0.Location = new System.Drawing.Point(617, 469);
            this.lblTTien_Nt0.Name = "lblTTien_Nt0";
            this.lblTTien_Nt0.Size = new System.Drawing.Size(51, 14);
            this.lblTTien_Nt0.TabIndex = 101;
            this.lblTTien_Nt0.Text = "Tổng tiền";
            // 
            // lblMa_Km
            // 
            this.lblMa_Km.AutoSize = true;
            this.lblMa_Km.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Km.Location = new System.Drawing.Point(12, 182);
            this.lblMa_Km.Name = "lblMa_Km";
            this.lblMa_Km.Size = new System.Drawing.Size(61, 14);
            this.lblMa_Km.TabIndex = 83;
            this.lblMa_Km.Text = "Khoản mục";
            // 
            // txtMa_Km
            // 
            this.txtMa_Km.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Km.CheckTextSearched = false;
            this.txtMa_Km.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Km.EmptyIsValid = true;
            this.txtMa_Km.FieldDisplay = "Ten_Km";
            this.txtMa_Km.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Km.FoundIsValid = true;
            this.txtMa_Km.Location = new System.Drawing.Point(99, 179);
            this.txtMa_Km.MaxLength = 32;
            this.txtMa_Km.Name = "txtMa_Km";
            this.txtMa_Km.OldValue = null;
            this.txtMa_Km.Size = new System.Drawing.Size(118, 20);
            this.txtMa_Km.TabIndex = 12;
            this.txtMa_Km.TableName = "DMKM";
            this.txtMa_Km.TextDisplay = this.txtTen_Km;
            this.txtMa_Km.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Km.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Km.Value = ((object)(resources.GetObject("txtMa_Km.Value")));
            this.txtMa_Km.Validated += new System.EventHandler(this.txtMa_Km_Validated);
            // 
            // txtTen_Km
            // 
            this.txtTen_Km.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Km.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Km.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Km.CheckTextSearched = false;
            this.txtTen_Km.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Km.Enabled = false;
            this.txtTen_Km.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Km.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Km.Location = new System.Drawing.Point(223, 182);
            this.txtTen_Km.Name = "txtTen_Km";
            this.txtTen_Km.OldValue = null;
            this.txtTen_Km.Size = new System.Drawing.Size(559, 13);
            this.txtTen_Km.TabIndex = 87;
            this.txtTen_Km.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_Km.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Km.Value = ((object)(resources.GetObject("txtTen_Km.Value")));
            // 
            // lblMa_Nx
            // 
            this.lblMa_Nx.AutoSize = true;
            this.lblMa_Nx.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Nx.Location = new System.Drawing.Point(12, 182);
            this.lblMa_Nx.Name = "lblMa_Nx";
            this.lblMa_Nx.Size = new System.Drawing.Size(72, 14);
            this.lblMa_Nx.TabIndex = 82;
            this.lblMa_Nx.Text = "Mã nhập xuất";
            // 
            // txtMa_Nx
            // 
            this.txtMa_Nx.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Nx.CheckTextSearched = false;
            this.txtMa_Nx.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Nx.EmptyIsValid = true;
            this.txtMa_Nx.FieldDisplay = "Ten_Nx";
            this.txtMa_Nx.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Nx.FoundIsValid = true;
            this.txtMa_Nx.Location = new System.Drawing.Point(99, 179);
            this.txtMa_Nx.MaxLength = 32;
            this.txtMa_Nx.Name = "txtMa_Nx";
            this.txtMa_Nx.OldValue = null;
            this.txtMa_Nx.Size = new System.Drawing.Size(118, 20);
            this.txtMa_Nx.TabIndex = 18;
            this.txtMa_Nx.TableName = "DMNX";
            this.txtMa_Nx.TextDisplay = this.txtTen_Nx;
            this.txtMa_Nx.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Nx.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Nx.Value = ((object)(resources.GetObject("txtMa_Nx.Value")));
            this.txtMa_Nx.Validated += new System.EventHandler(this.txtMa_Nx_Validated);
            // 
            // txtTen_Nx
            // 
            this.txtTen_Nx.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Nx.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Nx.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Nx.CheckTextSearched = false;
            this.txtTen_Nx.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nx.Enabled = false;
            this.txtTen_Nx.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Nx.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nx.Location = new System.Drawing.Point(223, 183);
            this.txtTen_Nx.Name = "txtTen_Nx";
            this.txtTen_Nx.OldValue = null;
            this.txtTen_Nx.Size = new System.Drawing.Size(559, 13);
            this.txtTen_Nx.TabIndex = 19;
            this.txtTen_Nx.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_Nx.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Nx.Value = ((object)(resources.GetObject("txtTen_Nx.Value")));
            // 
            // lblMa_KhoN
            // 
            this.lblMa_KhoN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.lblMa_KhoN.AutoSize = true;
            this.lblMa_KhoN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_KhoN.Location = new System.Drawing.Point(12, 469);
            this.lblMa_KhoN.Name = "lblMa_KhoN";
            this.lblMa_KhoN.Size = new System.Drawing.Size(53, 14);
            this.lblMa_KhoN.TabIndex = 99;
            this.lblMa_KhoN.Text = "Kho nhận";
            // 
            // grdDetail
            // 
            this.grdDetail.AllowUserToAddRows = false;
            this.grdDetail.AllowUserToDeleteRows = false;
            this.grdDetail.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.grdDetail.CheckAutoSize = true;
            this.grdDetail.CheckColor = false;
            this.grdDetail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column9,
            this.Column10,
            this.Column11,
            this.Column12,
            this.Column13,
            this.Column14,
            this.Column15,
            this.Column16,
            this.Column2,
            this.Column17,
            this.Column18,
            this.Column19,
            this.Column20,
            this.Column21,
            this.Column22,
            this.Column23,
            this.Column24});
            this.grdDetail.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdDetail.Location = new System.Drawing.Point(0, 201);
            this.grdDetail.Name = "grdDetail";
            this.grdDetail.Size = new System.Drawing.Size(794, 259);
            this.grdDetail.TabIndex = 20;
            this.grdDetail.CellRightLeaved += new System.EventHandler(this.grdDetail_CellRightLeaved);
            this.grdDetail.CellBottomLeftLeaved += new System.EventHandler(this.grdDetail_CellBottomLeftLeaved);
            // 
            // Column9
            // 
            this.Column9.DataPropertyName = "Ma_Vt";
            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column9.DefaultCellStyle = dataGridViewCellStyle1;
            this.Column9.DestinationFields = "Ten_Vt, Dvt";
            this.Column9.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column9.EmptyIsValid = true;
            this.Column9.HeaderText = "Mã số";
            this.Column9.MinimumWidth = 80;
            this.Column9.Name = "Column9";
            this.Column9.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column9.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column9.SourceFields = "Ten_Vt, Dvt";
            this.Column9.TableName = "DMVT";
            this.Column9.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.Column9.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.Column9.Width = 80;
            // 
            // Column10
            // 
            this.Column10.DataPropertyName = "Ten_Vt";
            this.Column10.HeaderText = "Tên vật liệu, phụ tùng";
            this.Column10.MinimumWidth = 140;
            this.Column10.Name = "Column10";
            this.Column10.ReadOnly = true;
            this.Column10.Width = 140;
            // 
            // Column11
            // 
            this.Column11.DataPropertyName = "Dvt";
            dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column11.DefaultCellStyle = dataGridViewCellStyle2;
            this.Column11.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column11.HeaderText = "Đvt";
            this.Column11.MinimumWidth = 40;
            this.Column11.Name = "Column11";
            this.Column11.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column11.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column11.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.Column11.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.Column11.Width = 40;
            // 
            // Column12
            // 
            this.Column12.DataPropertyName = "Ma_Kho";
            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column12.DefaultCellStyle = dataGridViewCellStyle3;
            this.Column12.DestinationFields = "Ten_Kho";
            this.Column12.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column12.HeaderText = "Kho";
            this.Column12.MinimumWidth = 50;
            this.Column12.Name = "Column12";
            this.Column12.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column12.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column12.SourceFields = "Ten_Kho";
            this.Column12.TableName = "DMKHO";
            this.Column12.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.Column12.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.Column12.Width = 50;
            // 
            // Column13
            // 
            this.Column13.DataPropertyName = "Ma_Bp";
            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column13.DefaultCellStyle = dataGridViewCellStyle4;
            this.Column13.DestinationFields = "Ten_Bp";
            this.Column13.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column13.EmptyIsValid = true;
            this.Column13.HeaderText = "Bộ phận";
            this.Column13.MinimumWidth = 80;
            this.Column13.Name = "Column13";
            this.Column13.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column13.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column13.SourceFields = "Ten_Bp";
            this.Column13.TableName = "DMBP";
            this.Column13.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.Column13.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.Column13.Width = 80;
            // 
            // Column14
            // 
            this.Column14.DataPropertyName = "Ma_Hd";
            dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column14.DefaultCellStyle = dataGridViewCellStyle5;
            this.Column14.DestinationFields = "Ten_Hd";
            this.Column14.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column14.EmptyIsValid = true;
            this.Column14.HeaderText = "Hợp đồng";
            this.Column14.Name = "Column14";
            this.Column14.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column14.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column14.SourceFields = "Ten_Hd";
            this.Column14.TableName = "DMHD";
            this.Column14.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.Column14.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.Column14.Width = 38;
            // 
            // Column15
            // 
            this.Column15.DataPropertyName = "Ma_Km";
            dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column15.DefaultCellStyle = dataGridViewCellStyle6;
            this.Column15.DestinationFields = "Ten_Km";
            this.Column15.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column15.EmptyIsValid = true;
            this.Column15.HeaderText = "Khoản mục";
            this.Column15.Name = "Column15";
            this.Column15.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column15.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column15.SourceFields = "Ten_Km";
            this.Column15.TableName = "DMKM";
            this.Column15.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.Column15.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.Column15.Width = 37;
            // 
            // Column16
            // 
            this.Column16.DataPropertyName = "Ma_Sp";
            dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column16.DefaultCellStyle = dataGridViewCellStyle7;
            this.Column16.DestinationFields = "Ten_Sp";
            this.Column16.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column16.EmptyIsValid = true;
            this.Column16.HeaderText = "Sản phẩm";
            this.Column16.Name = "Column16";
            this.Column16.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column16.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column16.SourceFields = "Ten_Sp";
            this.Column16.TableName = "DMSP";
            this.Column16.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.Column16.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.Column16.Width = 38;
            // 
            // Column2
            // 
            this.Column2.DataPropertyName = "Ma_Yt";
            dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column2.DefaultCellStyle = dataGridViewCellStyle8;
            this.Column2.DestinationFields = "Ten_Yt";
            this.Column2.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column2.EmptyIsValid = true;
            this.Column2.HeaderText = "Yếu tố";
            this.Column2.Name = "Column2";
            this.Column2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column2.SourceFields = "Ten_Yt";
            this.Column2.TableName = "DMYT";
            this.Column2.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.Column2.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.Column2.Width = 38;
            // 
            // Column17
            // 
            this.Column17.DataPropertyName = "Lo_Hang";
            dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column17.DefaultCellStyle = dataGridViewCellStyle9;
            this.Column17.DestinationFields = "Han_Dung, H_Luong, Do_Am_PT, Do_Con_PT";
            this.Column17.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column17.EmptyIsValid = true;
            this.Column17.HeaderText = "Lô hàng";
            this.Column17.Name = "Column17";
            this.Column17.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column17.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column17.SourceFields = "Han_Dung, H_Luong, Do_Am_PT, Do_Con_PT";
            this.Column17.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.Column17.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.Column17.Width = 38;
            // 
            // Column18
            // 
            this.Column18.DataPropertyName = "Han_Dung";
            dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column18.DefaultCellStyle = dataGridViewCellStyle10;
            this.Column18.HeaderText = "Hạn dùng";
            this.Column18.Name = "Column18";
            this.Column18.Resizable = System.Windows.Forms.DataGridViewTriState.False;
            this.Column18.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column18.Width = 62;
            // 
            // Column19
            // 
            this.Column19.DataPropertyName = "H_Luong";
            dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column19.DefaultCellStyle = dataGridViewCellStyle11;
            this.Column19.HeaderText = "Hàm lượng";
            this.Column19.Name = "Column19";
            this.Column19.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column19.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.Percent;
            this.Column19.Width = 26;
            // 
            // Column20
            // 
            this.Column20.DataPropertyName = "Do_Am_PT";
            dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column20.DefaultCellStyle = dataGridViewCellStyle12;
            this.Column20.HeaderText = "Độ ẩm";
            this.Column20.Name = "Column20";
            this.Column20.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column20.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.Percent;
            this.Column20.Width = 26;
            // 
            // Column21
            // 
            this.Column21.DataPropertyName = "Do_Con_PT";
            dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column21.DefaultCellStyle = dataGridViewCellStyle13;
            this.Column21.HeaderText = "Độ cồn";
            this.Column21.Name = "Column21";
            this.Column21.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column21.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.Percent;
            this.Column21.Width = 26;
            // 
            // Column22
            // 
            this.Column22.DataPropertyName = "So_Luong9";
            dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column22.DefaultCellStyle = dataGridViewCellStyle14;
            this.Column22.HeaderText = "Số lượng";
            this.Column22.MinimumWidth = 80;
            this.Column22.Name = "Column22";
            this.Column22.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column22.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.Quantity;
            this.Column22.Width = 80;
            this.Column22.ZeroIsValid = true;
            // 
            // Column23
            // 
            this.Column23.DataPropertyName = "Gia_Nt9";
            dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column23.DefaultCellStyle = dataGridViewCellStyle15;
            this.Column23.HeaderText = "Đơn giá";
            this.Column23.MinimumWidth = 80;
            this.Column23.Name = "Column23";
            this.Column23.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column23.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.ForeignPrice;
            this.Column23.Width = 80;
            this.Column23.ZeroIsValid = true;
            // 
            // Column24
            // 
            this.Column24.DataPropertyName = "Tien_Nt";
            dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column24.DefaultCellStyle = dataGridViewCellStyle16;
            this.Column24.HeaderText = "Thành tiền";
            this.Column24.MinimumWidth = 100;
            this.Column24.Name = "Column24";
            this.Column24.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column24.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.ForeignAmount;
            this.Column24.ZeroIsValid = true;
            // 
            // grdSubDetail
            // 
            this.grdSubDetail.AllowUserToAddRows = false;
            this.grdSubDetail.AllowUserToDeleteRows = false;
            this.grdSubDetail.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.grdSubDetail.CheckAutoSize = true;
            this.grdSubDetail.CheckColor = false;
            this.grdSubDetail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdSubDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.dataGridViewTextBoxColumn1,
            this.searchColumn3,
            this.Column1,
            this.searchColumn4,
            this.searchColumn5,
            this.searchColumn6,
            this.searchColumn1,
            this.searchColumn2});
            this.grdSubDetail.FirstColumnIndex = -1;
            this.grdSubDetail.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdSubDetail.Location = new System.Drawing.Point(0, 226);
            this.grdSubDetail.Name = "grdSubDetail";
            this.grdSubDetail.Size = new System.Drawing.Size(794, 234);
            this.grdSubDetail.TabIndex = 21;
            this.grdSubDetail.Visible = false;
            // 
            // dataGridViewTextBoxColumn1
            // 
            this.dataGridViewTextBoxColumn1.DataPropertyName = "Ten_Vt";
            this.dataGridViewTextBoxColumn1.HeaderText = "Tên vật tư";
            this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
            this.dataGridViewTextBoxColumn1.ReadOnly = true;
            this.dataGridViewTextBoxColumn1.Width = 351;
            // 
            // searchColumn3
            // 
            this.searchColumn3.DataPropertyName = "Dvt";
            this.searchColumn3.HeaderText = "Đvt";
            this.searchColumn3.Name = "searchColumn3";
            this.searchColumn3.ReadOnly = true;
            this.searchColumn3.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.searchColumn3.Width = 40;
            // 
            // Column1
            // 
            this.Column1.DataPropertyName = "So_Luong9";
            dataGridViewCellStyle17.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column1.DefaultCellStyle = dataGridViewCellStyle17;
            this.Column1.HeaderText = "Số lượng";
            this.Column1.Name = "Column1";
            this.Column1.ReadOnly = true;
            this.Column1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column1.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.Quantity;
            this.Column1.Width = 60;
            // 
            // searchColumn4
            // 
            this.searchColumn4.DataPropertyName = "Gia_Nt9";
            dataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.searchColumn4.DefaultCellStyle = dataGridViewCellStyle18;
            this.searchColumn4.HeaderText = "Đơn giá";
            this.searchColumn4.Name = "searchColumn4";
            this.searchColumn4.ReadOnly = true;
            this.searchColumn4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.searchColumn4.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.ForeignPrice;
            this.searchColumn4.Width = 70;
            // 
            // searchColumn5
            // 
            this.searchColumn5.DataPropertyName = "Tien_Nt";
            dataGridViewCellStyle19.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.searchColumn5.DefaultCellStyle = dataGridViewCellStyle19;
            this.searchColumn5.HeaderText = "Thành tiền";
            this.searchColumn5.Name = "searchColumn5";
            this.searchColumn5.ReadOnly = true;
            this.searchColumn5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.searchColumn5.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.ForeignAmount;
            this.searchColumn5.Width = 90;
            // 
            // searchColumn6
            // 
            this.searchColumn6.DataPropertyName = "Gia_Tb_Tt";
            dataGridViewCellStyle20.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.searchColumn6.DefaultCellStyle = dataGridViewCellStyle20;
            this.searchColumn6.DisabledForeColor = System.Drawing.Color.Blue;
            this.searchColumn6.HeaderText = "";
            this.searchColumn6.InputMask = "C,K";
            this.searchColumn6.Name = "searchColumn6";
            this.searchColumn6.Resizable = System.Windows.Forms.DataGridViewTriState.False;
            this.searchColumn6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.searchColumn6.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.searchColumn6.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.searchColumn6.Width = 20;
            // 
            // searchColumn1
            // 
            this.searchColumn1.DataPropertyName = "Tk_No";
            dataGridViewCellStyle21.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.searchColumn1.DefaultCellStyle = dataGridViewCellStyle21;
            this.searchColumn1.DisabledForeColor = System.Drawing.Color.Blue;
            this.searchColumn1.FirstFilter = "Loai_Tk = \'C\'";
            this.searchColumn1.HeaderText = "Tk nợ";
            this.searchColumn1.Name = "searchColumn1";
            this.searchColumn1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.searchColumn1.TableName = "DMTK";
            this.searchColumn1.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.searchColumn1.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.searchColumn1.Width = 60;
            // 
            // searchColumn2
            // 
            this.searchColumn2.DataPropertyName = "Tk_Co";
            dataGridViewCellStyle22.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.searchColumn2.DefaultCellStyle = dataGridViewCellStyle22;
            this.searchColumn2.DisabledForeColor = System.Drawing.Color.Blue;
            this.searchColumn2.FirstFilter = "Loai_Tk = \'C\'";
            this.searchColumn2.HeaderText = "Tk có";
            this.searchColumn2.Name = "searchColumn2";
            this.searchColumn2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.searchColumn2.TableName = "DMTK";
            this.searchColumn2.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.searchColumn2.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.searchColumn2.Width = 60;
            // 
            // txtMa_KhoN
            // 
            this.txtMa_KhoN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.txtMa_KhoN.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_KhoN.CheckTextSearched = false;
            this.txtMa_KhoN.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_KhoN.FieldDisplay = "Ten_Kho";
            this.txtMa_KhoN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_KhoN.FoundIsValid = true;
            this.txtMa_KhoN.Location = new System.Drawing.Point(99, 466);
            this.txtMa_KhoN.MaxLength = 32;
            this.txtMa_KhoN.Name = "txtMa_KhoN";
            this.txtMa_KhoN.OldValue = null;
            this.txtMa_KhoN.Size = new System.Drawing.Size(79, 20);
            this.txtMa_KhoN.TabIndex = 22;
            this.txtMa_KhoN.TableName = "DMKHO";
            this.txtMa_KhoN.TextDisplay = this.txtTen_KhoN;
            this.txtMa_KhoN.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_KhoN.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_KhoN.Value = ((object)(resources.GetObject("txtMa_KhoN.Value")));
            this.txtMa_KhoN.Validated += new System.EventHandler(this.txtMa_Nx_Validated);
            // 
            // txtTen_KhoN
            // 
            this.txtTen_KhoN.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_KhoN.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_KhoN.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_KhoN.CheckTextSearched = false;
            this.txtTen_KhoN.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_KhoN.Enabled = false;
            this.txtTen_KhoN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_KhoN.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_KhoN.Location = new System.Drawing.Point(184, 469);
            this.txtTen_KhoN.Name = "txtTen_KhoN";
            this.txtTen_KhoN.OldValue = null;
            this.txtTen_KhoN.Size = new System.Drawing.Size(142, 13);
            this.txtTen_KhoN.TabIndex = 23;
            this.txtTen_KhoN.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_KhoN.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_KhoN.Value = ((object)(resources.GetObject("txtTen_KhoN.Value")));
            // 
            // txtTen_DvCs
            // 
            this.txtTen_DvCs.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_DvCs.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_DvCs.CheckTextSearched = false;
            this.txtTen_DvCs.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_DvCs.Enabled = false;
            this.txtTen_DvCs.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_DvCs.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_DvCs.Location = new System.Drawing.Point(473, 469);
            this.txtTen_DvCs.Name = "txtTen_DvCs";
            this.txtTen_DvCs.OldValue = null;
            this.txtTen_DvCs.Size = new System.Drawing.Size(146, 13);
            this.txtTen_DvCs.TabIndex = 25;
            this.txtTen_DvCs.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_DvCs.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_DvCs.Value = ((object)(resources.GetObject("txtTen_DvCs.Value")));
            // 
            // txtMa_DvCsN
            // 
            this.txtMa_DvCsN.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_DvCsN.CheckTextSearched = false;
            this.txtMa_DvCsN.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_DvCsN.EmptyIsValid = true;
            this.txtMa_DvCsN.FieldDisplay = "Ten_DvCs";
            this.txtMa_DvCsN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_DvCsN.Location = new System.Drawing.Point(392, 465);
            this.txtMa_DvCsN.MaxLength = 32;
            this.txtMa_DvCsN.Name = "txtMa_DvCsN";
            this.txtMa_DvCsN.OldValue = null;
            this.txtMa_DvCsN.Size = new System.Drawing.Size(77, 20);
            this.txtMa_DvCsN.TabIndex = 24;
            this.txtMa_DvCsN.TableName = "DMDVCS";
            this.txtMa_DvCsN.TextDisplay = this.txtTen_DvCs;
            this.txtMa_DvCsN.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_DvCsN.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_DvCsN.Value = ((object)(resources.GetObject("txtMa_DvCsN.Value")));
            // 
            // lblMa_DvCsN
            // 
            this.lblMa_DvCsN.AutoSize = true;
            this.lblMa_DvCsN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_DvCsN.Location = new System.Drawing.Point(329, 468);
            this.lblMa_DvCsN.Name = "lblMa_DvCsN";
            this.lblMa_DvCsN.Size = new System.Drawing.Size(66, 14);
            this.lblMa_DvCsN.TabIndex = 104;
            this.lblMa_DvCsN.Text = "Đơn vị nhận";
            // 
            // FormCTNXEditor
            // 
            this.ClientSize = new System.Drawing.Size(794, 532);
            this.Controls.Add(this.txtTen_DvCs);
            this.Controls.Add(this.txtMa_DvCsN);
            this.Controls.Add(this.lblMa_DvCsN);
            this.Controls.Add(this.txtTTien_Nt0);
            this.Controls.Add(this.lblTTien_Nt0);
            this.Controls.Add(this.lblMa_KhoN);
            this.Controls.Add(this.txtMa_Tte);
            this.Controls.Add(this.txtTy_Gia);
            this.Controls.Add(this.txtDia_Chi);
            this.Controls.Add(this.txtOng_Ba);
            this.Controls.Add(this.txtTen_Dt);
            this.Controls.Add(this.lblMa_Tte);
            this.Controls.Add(this.txtMa_Dt);
            this.Controls.Add(this.lblDia_Chi);
            this.Controls.Add(this.lblOng_Ba);
            this.Controls.Add(this.lblMa_Dt);
            this.Controls.Add(this.txtDesc_EN);
            this.Controls.Add(this.txtDien_Giai);
            this.Controls.Add(this.txtTen_KhoN);
            this.Controls.Add(this.txtTen_Nx);
            this.Controls.Add(this.txtTen_Hd);
            this.Controls.Add(this.txtTen_Km);
            this.Controls.Add(this.txtTen_Bp);
            this.Controls.Add(this.lblDesc_EN);
            this.Controls.Add(this.lblDien_Giai);
            this.Controls.Add(this.txtMa_KhoN);
            this.Controls.Add(this.txtMa_Nx);
            this.Controls.Add(this.txtMa_Hd);
            this.Controls.Add(this.lblMa_Nx);
            this.Controls.Add(this.lblMa_Hd);
            this.Controls.Add(this.txtMa_Km);
            this.Controls.Add(this.lblMa_Km);
            this.Controls.Add(this.txtMa_Bp);
            this.Controls.Add(this.lblMa_Bp);
            this.Controls.Add(this.grdDetail);
            this.Controls.Add(this.grdSubDetail);
            this.Name = "FormCTNXEditor";
            this.Controls.SetChildIndex(this.grdSubDetail, 0);
            this.Controls.SetChildIndex(this.grdDetail, 0);
            this.Controls.SetChildIndex(this.lblPhan_Loai, 0);
            this.Controls.SetChildIndex(this.txtSo_Ct, 0);
            this.Controls.SetChildIndex(this.txtNgay_Ps, 0);
            this.Controls.SetChildIndex(this.txtNgay_Ct, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai1, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai2, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai3, 0);
            this.Controls.SetChildIndex(this.lblMa_Bp, 0);
            this.Controls.SetChildIndex(this.txtMa_Bp, 0);
            this.Controls.SetChildIndex(this.lblMa_Km, 0);
            this.Controls.SetChildIndex(this.txtMa_Km, 0);
            this.Controls.SetChildIndex(this.lblMa_Hd, 0);
            this.Controls.SetChildIndex(this.lblMa_Nx, 0);
            this.Controls.SetChildIndex(this.txtMa_Hd, 0);
            this.Controls.SetChildIndex(this.txtMa_Nx, 0);
            this.Controls.SetChildIndex(this.txtMa_KhoN, 0);
            this.Controls.SetChildIndex(this.lblDien_Giai, 0);
            this.Controls.SetChildIndex(this.lblDesc_EN, 0);
            this.Controls.SetChildIndex(this.txtTen_Bp, 0);
            this.Controls.SetChildIndex(this.txtTen_Km, 0);
            this.Controls.SetChildIndex(this.txtTen_Hd, 0);
            this.Controls.SetChildIndex(this.txtTen_Nx, 0);
            this.Controls.SetChildIndex(this.txtTen_KhoN, 0);
            this.Controls.SetChildIndex(this.txtDien_Giai, 0);
            this.Controls.SetChildIndex(this.txtDesc_EN, 0);
            this.Controls.SetChildIndex(this.lblMa_Dt, 0);
            this.Controls.SetChildIndex(this.lblOng_Ba, 0);
            this.Controls.SetChildIndex(this.lblDia_Chi, 0);
            this.Controls.SetChildIndex(this.txtMa_Dt, 0);
            this.Controls.SetChildIndex(this.lblMa_Tte, 0);
            this.Controls.SetChildIndex(this.txtTen_Dt, 0);
            this.Controls.SetChildIndex(this.txtOng_Ba, 0);
            this.Controls.SetChildIndex(this.txtDia_Chi, 0);
            this.Controls.SetChildIndex(this.txtTy_Gia, 0);
            this.Controls.SetChildIndex(this.txtMa_Tte, 0);
            this.Controls.SetChildIndex(this.lblMa_KhoN, 0);
            this.Controls.SetChildIndex(this.lblTTien_Nt0, 0);
            this.Controls.SetChildIndex(this.txtTTien_Nt0, 0);
            this.Controls.SetChildIndex(this.lblMa_DvCsN, 0);
            this.Controls.SetChildIndex(this.txtMa_DvCsN, 0);
            this.Controls.SetChildIndex(this.txtTen_DvCs, 0);
            ((System.ComponentModel.ISupportInitialize)(this.grdDetail)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.grdSubDetail)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        internal override void OnAdd()
        {
            object obj2 = base.LocalMasterRow["So_Ct"];
            base.LocalMasterRow = base.MakeMasterRow();
            base.LocalMasterRow["Nh_Ct"] = base.SSInvoiceParameters.InvoiceType;
            base.LocalMasterRow["So_Ct"] = this.oMethod.Cong_So_Ct(AppInstance.Subsidiary, base.InvoiceCode, base.LocalMasterRow["Ngay_Ct"], obj2);
            base.LocalMasterRow["Ma_Tte"] = AppInstance.DefaultCurrency;
            base.LocalMasterRow["Ty_Gia"] = 1;
            base.LocalMasterRow["Ty_Gia_Ht"] = 1;
            base.LocalMasterRow["TTien_Nt0"] = 0;
            base.LocalMasterRow["TTien0"] = 0;
            base.LocalMasterRow["PostedGL"] = 0;
            base.MakeDetailTable();
            base.LocalDetailTable.Rows[0]["Stt_Nv"] = 1;
            base.LocalDetailTable.Rows[0]["He_So9"] = 1;
            base.LocalDetailTable.Rows[0]["So_Luong9"] = 0;
            base.LocalDetailTable.Rows[0]["Gia_Nt9"] = 0;
            base.LocalDetailTable.Rows[0]["Gia9"] = 0;
            base.LocalDetailTable.Rows[0]["So_Luong"] = 0;
            base.LocalDetailTable.Rows[0]["Gia_Tb_Tt"] = "C";
            base.LocalDetailTable.Rows[0]["Gia_Nt"] = 0;
            base.LocalDetailTable.Rows[0]["Gia"] = 0;
            base.LocalDetailTable.Rows[0]["Tien_Nt"] = 0;
            base.LocalDetailTable.Rows[0]["Tien"] = 0;
            base.LocalDetailTable.Rows[0]["H_Luong"] = 0;
            base.LocalDetailTable.Rows[0]["Do_Am_PT"] = 0;
            base.LocalDetailTable.Rows[0]["Do_Con_PT"] = 0;
            if (base.SSInvoiceParameters.AllowDepartmentControl != 1)
            {
                base.LocalMasterRow["Ma_Bp"] = SDBNull.Value;
                base.LocalMasterRow["Ten_Bp"] = SDBNull.Value;
            }
            if (base.SSInvoiceParameters.AllowContractControl != 1)
            {
                base.LocalMasterRow["Ma_Hd"] = SDBNull.Value;
                base.LocalMasterRow["Ten_Hd"] = SDBNull.Value;
            }
            if (base.SSInvoiceParameters.AllowCategoryControl != 1)
            {
                base.LocalMasterRow["Ma_Km"] = SDBNull.Value;
                base.LocalMasterRow["Ten_Km"] = SDBNull.Value;
            }
            if (!base.SSInvoiceParameters.AllowProductControl)
            {
                base.LocalDetailTable.Rows[0]["Ma_Sp"] = SDBNull.Value;
                base.LocalDetailTable.Rows[0]["Ten_Sp"] = SDBNull.Value;
            }
            base.OnAdd();
        }

        internal override void OnCopy()
        {
            object obj2 = base.LocalMasterRow["So_Ct"];
            base.LocalMasterRow["So_Ct"] = this.oMethod.Cong_So_Ct(AppInstance.Subsidiary, base.InvoiceCode, base.LocalMasterRow["Ngay_Ct"], obj2);
            base.OnCopy();
        }

        internal override void OnResetControls()
        {
            base.DetailGridBrowser = this.grdDetail;
            base.DetailSubBrowser = this.grdSubDetail;
            int num = 0;
            if (base.SSInvoiceParameters.AllowDepartmentControl != 1)
            {
                num += this.txtMa_Hd.Top - this.txtMa_Bp.Top;
                this.lblMa_Bp.Visible = false;
                this.txtMa_Bp.Visible = false;
                this.txtTen_Bp.Visible = false;
            }
            if (base.SSInvoiceParameters.AllowContractControl != 1)
            {
                num += this.txtMa_Dt.Top - this.txtMa_Hd.Top;
                this.lblMa_Hd.Visible = false;
                this.txtMa_Hd.Visible = false;
                this.txtTen_Hd.Visible = false;
            }
            if (num != 0)
            {
                if (base.SSInvoiceParameters.AllowContractControl == 1)
                {
                    this.lblMa_Hd.Top -= num;
                    this.txtMa_Hd.Top -= num;
                    this.txtTen_Hd.Top -= num;
                }
                this.lblMa_Dt.Top -= num;
                this.txtMa_Dt.Top -= num;
                this.txtTen_Dt.Top -= num;
                this.lblOng_Ba.Top -= num;
                this.txtOng_Ba.Top -= num;
                this.lblDia_Chi.Top -= num;
                this.txtDia_Chi.Top -= num;
                this.lblDien_Giai.Top -= num;
                this.txtDien_Giai.Top -= num;
                this.lblDesc_EN.Top -= num;
                this.txtDesc_EN.Top -= num;
            }
            if (base.SSInvoiceParameters.AllowCategoryControl != 1)
            {
                num += this.txtMa_Nx.Top - this.txtMa_Km.Top;
                this.lblMa_Km.Visible = false;
                this.txtMa_Km.Visible = false;
                this.txtTen_Km.Visible = false;
            }
            else
            {
                this.lblMa_Km.Top -= num;
                this.txtMa_Km.Top -= num;
                this.txtTen_Km.Top -= num;
            }
            if (num != 0)
            {
                this.lblMa_Nx.Top -= num;
                this.txtMa_Nx.Top -= num;
                this.txtTen_Nx.Top -= num;
                this.grdDetail.Top -= num;
                this.grdDetail.Height += num;
                this.grdSubDetail.Top -= num;
                this.grdSubDetail.Height += num;
            }
            if (!base.SSInvoiceParameters.BilingualUsed)
            {
                this.lblDesc_EN.Visible = false;
                this.txtDesc_EN.Visible = false;
                this.txtDien_Giai.Width = (this.txtDesc_EN.Left + this.txtDesc_EN.Width) - this.txtDien_Giai.Left;
                this.txtDien_Giai.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            }
            if (base.SSInvoiceParameters.AllowDepartmentControl != 2)
            {
                base.DetailGridBrowser.Columns[4].Visible = false;
            }
            if (base.SSInvoiceParameters.AllowContractControl != 2)
            {
                base.DetailGridBrowser.Columns[5].Visible = false;
            }
            if (base.SSInvoiceParameters.AllowCategoryControl != 2)
            {
                base.DetailGridBrowser.Columns[6].Visible = false;
            }
            if (!base.SSInvoiceParameters.AllowProductControl || (base.InvoiceCode == "PNTP"))
            {
                base.DetailGridBrowser.Columns[7].Visible = false;
            }
            if (base.InvoiceCode != "PNSP")
            {
                base.DetailGridBrowser.Columns[8].Visible = false;
            }
            if (!AppInstance.LotNumberCtrl)
            {
                base.DetailGridBrowser.Columns[9].Visible = false;
            }
            if (!AppInstance.DeadLineCtrl)
            {
                base.DetailGridBrowser.Columns[10].Visible = false;
            }
            if (!AppInstance.QualityCtrl)
            {
                base.DetailGridBrowser.Columns[11].Visible = false;
            }
            if (!AppInstance.DampCtrl)
            {
                base.DetailGridBrowser.Columns[12].Visible = false;
            }
            if (!AppInstance.AlcoholCtrl)
            {
                base.DetailGridBrowser.Columns[13].Visible = false;
            }
            if (base.SSInvoiceParameters.FreeFields <= 0)
            {
                num = base.txtMa_Loai1.Top - this.txtMa_KhoN.Top;
                this.lblMa_KhoN.Top += num;
                this.txtMa_KhoN.Top += num;
                this.txtTen_KhoN.Top += num;
                this.lblMa_DvCsN.Top += num;
                this.txtMa_DvCsN.Top += num;
                this.txtTen_DvCs.Top += num;
                this.lblTTien_Nt0.Top += num;
                this.txtTTien_Nt0.Top += num;
                this.grdDetail.Height += num;
                this.grdSubDetail.Height += num;
            }
            if (base.InvoiceCode != "PXDC")
            {
                if (base.InvoiceCode == "PCTB" || base.InvoiceCode == "PCPT")
                {
                    this.lblMa_KhoN.Visible = true;
                    this.txtMa_KhoN.Visible = true;
                    this.txtTen_KhoN.Visible = true;
                    this.lblMa_DvCsN.Visible = true;
                    this.txtMa_DvCsN.Visible = true;
                    this.txtTen_DvCs.Visible = true;

                }                
                else 
                {
                    this.lblMa_KhoN.Visible = false;
                    this.txtMa_KhoN.Visible = false;
                    this.txtTen_KhoN.Visible = false;
                    this.lblMa_DvCsN.Visible = false;
                    this.txtMa_DvCsN.Visible = false;
                    this.txtTen_DvCs.Visible = false;
                }

            }

            if (base.InvoiceCode == "PXDC")
            {
                this.lblMa_DvCsN.Visible = false;
                this.txtMa_DvCsN.Visible = false;
                this.txtTen_DvCs.Visible = false;
            }

            if (base.SSInvoiceParameters.InvoiceType == "2")
            {
                (base.DetailGridBrowser.Columns[9] as SearchLotNumberColumn).TableName = "LOHANG";
                base.DetailGridBrowser.Columns[10].ReadOnly = true;
                base.DetailGridBrowser.Columns[11].ReadOnly = true;
                base.DetailGridBrowser.Columns[12].ReadOnly = true;
                base.DetailGridBrowser.Columns[13].ReadOnly = true;
            }
            else
            {
                (base.DetailGridBrowser.Columns[9] as SearchLotNumberColumn).TableName = "";
            }
            base.OnResetControls();
        }

        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            if (this.txtOng_Ba != null)
            {
                int num = base.ClientSize.Width - 0xcb;
                this.txtOng_Ba.Width = num / 2;
                this.txtDia_Chi.Left = (this.txtOng_Ba.Left + this.txtOng_Ba.Width) + 0x5c;
                this.txtDia_Chi.Width = num - this.txtOng_Ba.Width;
                this.lblDia_Chi.Left = (this.txtDia_Chi.Left - this.lblDia_Chi.Width) - 6;
                if ((base.SSInvoiceParameters != null) && base.SSInvoiceParameters.BilingualUsed)
                {
                    this.txtDien_Giai.Width = this.txtOng_Ba.Width;
                    this.txtDesc_EN.Left = this.txtDia_Chi.Left;
                    this.txtDesc_EN.Width = this.txtDia_Chi.Width;
                    this.lblDesc_EN.Left = (this.txtDesc_EN.Left - this.lblDesc_EN.Width) - 6;
                }
            }
        }

        protected override bool OnSave()
        {
            if (base.txtNgay_Ps.Value == SDBNull.Value)
            {
                MessageBox.Show("Chưa nhập ngày phát sinh!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.txtNgay_Ct.Value == SDBNull.Value)
            {
                MessageBox.Show("Chưa nhập ngày chứng từ!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (((DateTime) base.txtNgay_Ct.Value) < AppInstance.OpeningDateOfSubEnterprice)
            {
                MessageBox.Show("Ngày chứng từ phải từ ngày " + AppInstance.OpeningDateOfSubEnterprice.ToShortDateString(), AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (((DateTime) base.txtNgay_Ct.Value) <= AppInstance.EndingDateOfSubEnterprice)
            {
                MessageBox.Show("Ngày chứng từ phải từ ngày " + AppInstance.EndingDateOfSubEnterprice.AddDays(1.0).ToShortDateString(), AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            foreach (DataRow row in base.LocalDetailTable.Rows)
            {
                if ((row.RowState != DataRowState.Deleted) && string.IsNullOrEmpty(row["Ma_Kho"].ToString()))
                {
                    MessageBox.Show("Không được để mã kho trống!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return false;
                }
            }
            if ((base.InvoiceCode == "PXDC") && string.IsNullOrEmpty(this.txtMa_KhoN.Text))
            {
                MessageBox.Show("Không được để mã kho nhập trống!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (!base.CheckNewRow)
            {
                int num = this.oMethod.CheckInvoiceStatus(AppInstance.Subsidiary, AppInstance.UserName, base.SavedMasterOrder);
                switch (num)
                {
                    case 9:
                    case 7:
                        break;

                    default:
                        if ((base.SSInvoiceParameters.AllowPostInvoice && base.SSInvoiceParameters.AllowLockInvoice) || ((num != 6) && (num != 5)))
                        {
                            if (num == 8)
                            {
                                base.SSInvoiceParameters.ShowInvoiceUsed(base.SavedMasterOrder, base.SSInvoiceParameters.StatusMessage(num));
                                return false;
                            }
                            goto Label_022E;
                        }
                        break;
                }
                MessageBox.Show(base.SSInvoiceParameters.StatusMessage(num), AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
        Label_022E:
            if (this.oMethod.NumberExisted(AppInstance.Subsidiary, base.CheckNewRow, base.SavedMasterOrder, base.InvoiceCode, base.txtNgay_Ct.Value, base.txtSo_Ct.Value) && (MessageBox.Show("Số chứng từ đã tồn tại. C\x00f3 tiếp tục không?", AppInstance.SoftwareName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No))
            {
                if (MessageBox.Show("C\x00f3 muốn tự động tạo số chứng từ không?", AppInstance.SoftwareName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return false;
                }
                object obj2 = base.txtSo_Ct.Value;
                base.txtSo_Ct.Value = this.oMethod.Cong_So_Ct(AppInstance.Subsidiary, base.InvoiceCode, base.LocalMasterRow["Ngay_Ct"], obj2);
            }
            base.DetailGridBrowser.EndEdit();
            base.LocalMasterRow["Ngay_Ps"] = base.txtNgay_Ps.Value;
            base.LocalMasterRow["Ngay_Ct"] = base.txtNgay_Ct.Value;
            base.LocalMasterRow["So_Ct"] = base.txtSo_Ct.Value;
            base.LocalMasterRow["Ma_Tte"] = this.txtMa_Tte.Value;
            base.LocalMasterRow["Ty_Gia"] = this.txtTy_Gia.Value;
            base.LocalMasterRow["Ty_Gia_Ht"] = base.ExchangeRate;
            base.LocalMasterRow["Ma_Bp"] = this.txtMa_Bp.Value;
            base.LocalMasterRow["Ten_Bp"] = this.txtTen_Bp.Value;
            base.LocalMasterRow["Ma_Hd"] = this.txtMa_Hd.Value;
            base.LocalMasterRow["Ten_Hd"] = this.txtTen_Hd.Value;
            base.LocalMasterRow["Ma_Dt"] = this.txtMa_Dt.Value;
            base.LocalMasterRow["Ten_Dt"] = this.txtTen_Dt.Value;
            base.LocalMasterRow["Ong_Ba"] = this.txtOng_Ba.Value;
            base.LocalMasterRow["Dia_Chi"] = this.txtDia_Chi.Value;
            base.LocalMasterRow["Dien_Giai"] = this.txtDien_Giai.Value;
            base.LocalMasterRow["Desc_EN"] = this.txtDesc_EN.Value;
            base.LocalMasterRow["Ma_Km"] = this.txtMa_Km.Value;
            base.LocalMasterRow["Ten_Km"] = this.txtTen_Km.Value;
            base.LocalMasterRow["Ma_Nx"] = this.txtMa_Nx.Value;
            base.LocalMasterRow["Ten_Nx"] = this.txtTen_Nx.Value;
            base.LocalMasterRow["Ma_KhoN"] = this.txtMa_KhoN.Value;
            base.LocalMasterRow["Ten_KhoN"] = this.txtTen_KhoN.Value;
            base.LocalMasterRow["Ma_DvCsN"] = this.txtMa_DvCsN.Value;
            base.LocalMasterRow["Ten_DvCs"] = this.txtTen_DvCs.Value;

            base.LocalMasterRow["TTien_Nt0"] = this.txtTTien_Nt0.Value;
            base.LocalMasterRow["Ma_Loai1"] = base.txtMa_Loai1.Value;
            base.LocalMasterRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            base.LocalMasterRow["Ma_Loai3"] = base.txtMa_Loai3.Value;
            bool flag = true;
            if (this.oMethod.Save(base.SSInvoiceParameters.InvoiceHistory, base.CheckNewRow, AppInstance.Subsidiary, AppInstance.UserName, base.LocalMasterRow, base.LocalDetailTable, ref flag))
            {
                return base.OnSave();
            }
            if (!flag)
            {
                if (base.InvoiceCode == "PNTP")
                {
                    MessageBox.Show("Phiếu nhập thành phẩm đã thực hiện qu\x00e1 lệnh sản xuất!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else if (base.SSInvoiceParameters.InvoiceType == "1")
                {
                    MessageBox.Show("Phiếu nhập lại đã thực hiện qu\x00e1 phiếu xuất!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    MessageBox.Show("Phiếu xuất đã thực hiện qu\x00e1 yêu cầu vật tư!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            return false;
        }

        internal override void OnShow()
        {
            base.OnShow();
            this.txtMa_Tte.Value = base.LocalMasterRow["Ma_Tte"];
            this.txtTy_Gia.Value = base.LocalMasterRow["Ty_Gia"];
            this.txtMa_Bp.Value = base.LocalMasterRow["Ma_Bp"];
            this.txtTen_Bp.Value = base.LocalMasterRow["Ten_Bp"];
            this.txtMa_Hd.Value = base.LocalMasterRow["Ma_Hd"];
            this.txtTen_Hd.Value = base.LocalMasterRow["Ten_Hd"];
            this.txtMa_Dt.Value = base.LocalMasterRow["Ma_Dt"];
            this.txtTen_Dt.Value = base.LocalMasterRow["Ten_Dt"];
            this.txtOng_Ba.Value = base.LocalMasterRow["Ong_Ba"];
            this.txtDia_Chi.Value = base.LocalMasterRow["Dia_Chi"];
            this.txtDien_Giai.Value = base.LocalMasterRow["Dien_Giai"];
            this.txtDesc_EN.Value = base.LocalMasterRow["Desc_EN"];
            this.txtMa_Km.Value = base.LocalMasterRow["Ma_Km"];
            this.txtTen_Km.Value = base.LocalMasterRow["Ten_Km"];
            this.txtMa_Nx.Value = base.LocalMasterRow["Ma_Nx"];
            this.txtTen_Nx.Value = base.LocalMasterRow["Ten_Nx"];
            this.txtMa_KhoN.Value = base.LocalMasterRow["Ma_KhoN"];
            this.txtTen_KhoN.Value = base.LocalMasterRow["Ten_KhoN"];
            this.txtMa_DvCsN.Value = base.LocalMasterRow["Ma_DvCsN"];
            this.txtTen_DvCs.Value = base.LocalMasterRow["Ten_DvCs"];

            this.txtTTien_Nt0.Value = base.LocalMasterRow["TTien_Nt0"];
            base.TranCurrencyCode = this.txtMa_Tte.Text;
            if (!base.CheckNewRow)
            {
                base.ExchangeRateOfBook = (decimal) this.txtTy_Gia.Value;
            }
        }

        internal override void OnShowDetailNotice()
        {
            DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
            object obj2 = ((base.SSInvoiceParameters.InvoiceCode == "PNDC") && !string.IsNullOrEmpty(this.txtMa_KhoN.Text)) ? this.txtMa_KhoN.Value : SDBNull.Value;
            string str = "";
            base.SSInvoiceParameters.MakeQtyWarningMessage(true, base.LocalMasterRow["Posted"], base.SavedMasterOrder, base.SavedDetailOrder, base.txtNgay_Ct.Value, base.SSInvoiceParameters.InvoiceType, row["Ma_Kho"], row["Ma_Vt"], obj2, base.LocalDetailTable, ref str);
            base.WarningMessage = str;
            base.OnShowDetailNotice();
        }

        private void SetFunctions()
        {
            ToolStripMenuItem item = new ToolStripMenuItem();
            item.AutoSize = true;
            if (base.InvoiceCode == "PNTP")
            {
                item.Text = "Chọn lệnh sản xuất";
                item.Click += new EventHandler(this.ChooseCommand);
                base.ToolStripFunctions = new ToolStripItem[] { item };
            }
            else if (base.InvoiceCode == "PXSP")
            {
                item.Text = "Chọn lệnh sản xuất";
                item.Click += new EventHandler(this.ChooseCommandItem);
                base.ToolStripFunctions = new ToolStripItem[] { item };
            }
            else
            {
                base.ToolStripFunctions = null;
            }
        }

        private void SetItemRatio()
        {
            DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
            DataRow row2 = SSDataAccess.SelectDataRow(false, "DMVT", "Ma_Vt", row["Ma_Vt"].ToString(), null);
            if (row2 != null)
            {
                if (row["Dvt"].Equals(row2["Dvt"]))
                {
                    row["He_So9"] = 1;
                }
                else if (row["Dvt"].Equals(row2["Dvt0"]))
                {
                    row["He_So9"] = row2["He_So0"];
                }
                else if (row["Dvt"].Equals(row2["Dvt1"]))
                {
                    row["He_So9"] = row2["He_So1"];
                }
                else if (row["Dvt"].Equals(row2["Dvt2"]))
                {
                    row["He_So9"] = row2["He_So2"];
                }
                row.EndEdit();
                this.Calculate(row, 2);
                this.Sum();
            }
        }

        private void SetItemUnits()
        {
            DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
            DataRow row2 = SSDataAccess.SelectDataRow(false, "DMVT", "Ma_Vt", row["Ma_Vt"].ToString(), null);
            if (row2 != null)
            {
                if (string.IsNullOrEmpty(row2["Dvt0"].ToString()))
                {
                    base.DetailGridBrowser.CurrentCell.ReadOnly = true;
                }
                else
                {
                    string str = (string.IsNullOrEmpty(row2["Dvt"].ToString()) ? "" : row2["Dvt"].ToString()) + (string.IsNullOrEmpty(row2["Dvt0"].ToString()) ? "" : ("," + row2["Dvt0"].ToString())) + (string.IsNullOrEmpty(row2["Dvt1"].ToString()) ? "" : ("," + row2["Dvt1"].ToString())) + (string.IsNullOrEmpty(row2["Dvt2"].ToString()) ? "" : ("," + row2["Dvt2"].ToString())) + (string.IsNullOrEmpty(row2["Dvt3"].ToString()) ? "" : ("," + row2["Dvt3"].ToString()));
                    (base.DetailGridBrowser.CurrentCell as OptionCell).InputMask = str;
                    base.DetailGridBrowser.CurrentCell.ReadOnly = false;
                }
            }
        }

        private bool Sum()
        {
            decimal num = 0M;
            decimal num2 = 0M;
            foreach (DataRow row in base.LocalDetailTable.Rows)
            {
                if (row.RowState != DataRowState.Deleted)
                {
                    num += (decimal) row["Tien_Nt"];
                    num2 += (decimal) row["Tien"];
                }
            }
            base.LocalMasterRow["TTien_Nt0"] = num;
            base.LocalMasterRow["TTien0"] = num2;
            this.txtTTien_Nt0.Value = num;
            return true;
        }

        private void txtMa_Bp_Validated(object sender, EventArgs e)
        {
            if (this.txtMa_Bp.ValueChanged)
            {
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if ((row.RowState != DataRowState.Deleted) && (this.txtMa_Bp.OldValue.Equals(row["Ma_Bp"]) || (this.txtMa_Bp.OldValue.ToString() == row["Ma_Bp"].ToString())))
                    {
                        row["Ma_Bp"] = this.txtMa_Bp.Value;
                        row["Ten_Bp"] = this.txtTen_Bp.Value;
                    }
                }
            }
        }

        private void txtMa_Dt_Validated(object sender, EventArgs e)
        {
            if (this.txtMa_Dt.ValueChanged)
            {
                this.txtOng_Ba.Value = this.txtMa_Dt.GetFieldData("Doi_Tac").Equals(DBNull.Value) ? this.txtTen_Dt.Value : this.txtMa_Dt.GetFieldData("Doi_Tac");
                this.txtDia_Chi.Value = this.txtMa_Dt.GetFieldData("Dia_Chi");
            }
        }

        private void txtMa_Hd_Validated(object sender, EventArgs e)
        {
            if (this.txtMa_Hd.ValueChanged)
            {
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if ((row.RowState != DataRowState.Deleted) && (this.txtMa_Hd.OldValue.Equals(row["Ma_Hd"]) || (this.txtMa_Hd.OldValue.ToString() == row["Ma_Hd"].ToString())))
                    {
                        row["Ma_Hd"] = this.txtMa_Hd.Value;
                        row["Ten_Hd"] = this.txtTen_Hd.Value;
                    }
                }
            }
        }

        private void txtMa_Km_Validated(object sender, EventArgs e)
        {
            if (this.txtMa_Km.ValueChanged)
            {
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if ((row.RowState != DataRowState.Deleted) && (this.txtMa_Km.OldValue.Equals(row["Ma_Km"]) || (this.txtMa_Km.OldValue.ToString() == row["Ma_Km"].ToString())))
                    {
                        row["Ma_Km"] = this.txtMa_Km.Value;
                        row["Ten_Km"] = this.txtTen_Km.Value;
                    }
                }
            }
        }

        private void txtMa_Nx_Validated(object sender, EventArgs e)
        {
            if (this.txtMa_Nx.ValueChanged)
            {
                base.LocalMasterRow["PostedGL"] = this.txtMa_Nx.GetFieldData("Post_GL").ToString() == "C";
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if (row.RowState != DataRowState.Deleted)
                    {
                        if (base.SSInvoiceParameters.InvoiceType == "1")
                        {
                            row["Tk_Co"] = this.txtMa_Nx.GetFieldData("Tk");
                        }
                        else
                        {
                            row["Tk_No"] = this.txtMa_Nx.GetFieldData("Tk");
                        }
                    }
                }
            }
        }

        private void txtMa_Tte_Validated(object sender, EventArgs e)
        {
            if (((base.SSInvoiceParameters != null) && (base.LocalMasterRow != null)) && this.txtMa_Tte.ValueChanged)
            {
                base.TranCurrencyCode = this.txtMa_Tte.Text;
                this.txtTy_Gia.Value = base.ExchangeRateOfBook;
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if (row.RowState != DataRowState.Deleted)
                    {
                        this.Calculate(row, 2);
                    }
                }
                this.Sum();
            }
        }

        private void txtTy_Gia_Validated(object sender, EventArgs e)
        {
            if (this.txtTy_Gia.ValueChanged)
            {
                base.ExchangeRateOfBook = (decimal) this.txtTy_Gia.Value;
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if (row.RowState != DataRowState.Deleted)
                    {
                        this.Calculate(row, 2);
                    }
                }
                this.Sum();
            }
        }

        private void UpdateVtParameters()
        {
            DataRow row = ((DataRowView) this.grdDetail.CurrentRow.DataBoundItem).Row;
            DataRow row2 = SSDataAccess.SelectDataRow(false, "DMVT", "Ma_Vt", row["Ma_Vt"].ToString(), null);
            if (row2 != null)
            {
                if (base.SSInvoiceParameters.InvoiceType == "1")
                {
                    row["Tk_No"] = row2["Tk_Vt"];
                    row["Tk_Co"] = this.txtMa_Nx.GetFieldData("Tk");
                }
                else
                {
                    row["Tk_No"] = this.txtMa_Nx.GetFieldData("Tk");
                    row["Tk_Co"] = row2["Tk_Vt"];
                }
                this.SetItemRatio();
            }
        }

        private void UpdateVtParameters(DataRow po_Row)
        {
            DataRow row = SSDataAccess.SelectDataRow(false, "DMVT", "Ma_Vt", po_Row["Ma_Vt"].ToString(), null);
            if (row != null)
            {
                if (base.SSInvoiceParameters.InvoiceType == "1")
                {
                    po_Row["Tk_No"] = row["Tk_Vt"];
                    po_Row["Tk_Co"] = this.txtMa_Nx.GetFieldData("Tk");
                }
                else
                {
                    po_Row["Tk_No"] = this.txtMa_Nx.GetFieldData("Tk");
                    po_Row["Tk_Co"] = row["Tk_Vt"];
                }
            }
        }
    }
}

